How to use the @orbit/data.Schema function in @orbit/data

To help you get started, we’ve selected a few @orbit/data examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sillsdev / web-languageforge / src / SIL.XForge.Scripture / ClientApp / src / xforge-common / orbit-service.ts View on Github external
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
github orbitjs / ember-orbit / addon / schema.js View on Github external
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);
    }
  },
github sillsdev / web-languageforge / src / SIL.XForge.Scripture / ClientApp / src / xforge-common / strategies / remote-pull-fail-strategy.spec.ts View on Github external
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')]
    });
  }
github orbitjs / ember-orbit / addon / -private / factories / schema-factory.js View on Github external
relationships: model.relationships
        };
      });

      injections.models = modelSchemas;
    }

    if (!injections.pluralize) {
      injections.pluralize = pluralize;
    }

    if (!injections.singularize) {
      injections.singularize = singularize;
    }

    return new Schema(injections);
  }
};
github spree / spree-storefront-api-v2-js-sdk / src / Orbit.ts View on Github external
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({
github sillsdev / appbuilder-portal / source / SIL.AppBuilder.Portal.Frontend / src / data / schema.ts View on Github external
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);
github sillsdev / web-languageforge / src / SIL.XForge.Scripture / ClientApp / src / xforge-common / strategies / remote-push-fail-strategy.spec.ts View on Github external
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')]
    });
  }
github sillsdev / web-languageforge / src / SIL.XForge.Scripture / ClientApp / src / xforge-common / json-api.service.spec.ts View on Github external
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: {