Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async init(accessToken: string): Promise {
const schemaDef = await this.http
.get(`${NAMESPACE}/schema`, { headers: { 'Content-Type': 'application/json' } })
.toPromise();
schemaDef.generateId = () => objectId();
this._schema = new Schema(schemaDef);
this.bucket = new IndexedDBBucket({
namespace: 'xforge-state'
});
this._store = new XForgeStore({
schema: this._schema,
bucket: this.bucket
});
this.remote = new XForgeJSONAPISource({
schema: this._schema,
bucket: this.bucket,
name: REMOTE,
host: this.locationService.origin,
namespace: NAMESPACE
options.pluralize = pluralize;
}
const singularize = get(this, 'singularize');
if (singularize) {
options.singularize = singularize;
}
let modelDefinitions = get(this, 'modelDefinitions');
if (!modelDefinitions) {
modelDefinitions = this._buildModelDefinitions();
}
options.models = modelDefinitions;
this.orbitSchema = new OrbitSchema(options);
}
},
constructor() {
this.schema = new Schema(TEST_SCHEMA_SETTINGS);
this.remote = new TestSource({ name: 'remote' });
this.store = new XForgeStore({
name: 'store',
schema: this.schema
});
this.store.cache.patch(t => [
t.addRecord({ type: 'user', id: 'user01', attributes: { name: 'User 1' } }),
t.addRecord({ type: 'user', id: 'user02', attributes: { name: 'User 2' } })
]);
this.coordinator = new Coordinator({
sources: [this.remote, this.store],
strategies: [new RemotePullFailStrategy('remote'), new StoreRemoteQueryStrategy('store', 'remote')]
});
}
relationships: model.relationships
};
});
injections.models = modelSchemas;
}
if (!injections.pluralize) {
injections.pluralize = pluralize;
}
if (!injections.singularize) {
injections.singularize = singularize;
}
return new Schema(injections);
}
};
constructor() {
this.currentSchema = currentSchema
this.schema = new Schema(currentSchema)
this.remote = new JSONAPISource({ schema: this.schema, name: 'remote', host: 'http://localhost:5000/api/v2/storefront' })
this.coordinator = new Coordinator()
this.store = new Store({ schema: this.schema, name: 'store' })
this.coordinator.addSource(this.store)
this.coordinator.addSource(this.remote)
this.coordinator.addStrategy(new RequestStrategy({
source: 'store',
on: 'beforeQuery',
target: 'remote',
action: 'pull',
blocking: true
}))
this.coordinator.addStrategy(new SyncStrategy({
attributes: {
message: { type: 'string' },
dateRead: { type: 'date' },
dateEmailSent: { type: 'date' },
dateCreated: { type: 'date' },
dateUpdated: { type: 'date' },
sendEmail: { type: 'boolean' },
},
relationships: {
user: { type: 'hasOne', model: 'user', inverse: 'notifications' },
},
},
},
};
export const schema = new Schema(schemaDefinition);
constructor() {
this.schema = new Schema(TEST_SCHEMA_SETTINGS);
this.remote = new TestSource({ name: 'remote' });
this.store = new XForgeStore({
name: 'store',
schema: this.schema
});
this.store.cache.patch(t => [
t.addRecord({ type: 'user', id: 'user01', attributes: { name: 'User 1' } }),
t.addRecord({ type: 'user', id: 'user02', attributes: { name: 'User 2' } })
]);
this.coordinator = new Coordinator({
sources: [this.remote, this.store],
strategies: [new RemotePushFailStrategy('remote', 'store', 10), new StoreRemoteUpdateStrategy('store', 'remote')]
});
}
constructor() {
super();
const domainModel = new DomainModel({
resourceTypes: [TestProject, TestProjectUser],
resourceRefTypes: [TestProjectRef, TestProjectUserRef],
realtimeDataTypes: []
});
this.schema = new Schema(TEST_SCHEMA_SETTINGS);
this.store = new XForgeStore({ schema: this.schema });
this.store.cache.patch(t => [
t.addRecord({
type: 'user',
id: 'user01',
attributes: { name: 'User 1', site: { currentProjectId: 'project01' } }
}),
t.addRecord({ type: 'user', id: 'user02', attributes: { name: 'User 2' } }),
t.addRecord({ type: 'project', id: 'project01', attributes: { projectName: 'Project 1', num: 1 } }),
t.addRecord({ type: 'project', id: 'project02', attributes: { projectName: 'Project 2', num: 2 } }),
t.addRecord({ type: 'project', id: 'project03', attributes: { projectName: 'Project 3', num: 3 } }),
t.addRecord({
type: 'projectUser',
id: 'projectuser01',
attributes: { role: 'admin', name: 'Project User 1' },
relationships: {