@contember/engine-http 2.0.0-alpha.35 → 2.0.0-alpha.36

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -27,12 +27,12 @@ const cache = new ContentApiSpecificCache.ContentApiSpecificCache({});
27
27
  const getSchema = (schema, options) => {
28
28
  const cacheKey = [options.stage, options.normalize].join("ÿ");
29
29
  return cache.fetch(schema, cacheKey, () => {
30
- const result = schema;
30
+ let result = schema;
31
31
  if (options.normalize) {
32
- return schemaUtils.normalizeSchema(result);
32
+ result = schemaUtils.normalizeSchema(result);
33
33
  }
34
34
  if (options.stage) {
35
- return schemaUtils.filterSchemaByStage(result, options.stage);
35
+ result = schemaUtils.filterSchemaByStage(result, options.stage);
36
36
  }
37
37
  return result;
38
38
  });
@@ -1 +1 @@
1
- {"version":3,"file":"ContentSchemaResolver.cjs","sources":["../../../../../packages/engine-http/src/content/ContentSchemaResolver.ts"],"sourcesContent":["import { DatabaseContext, SchemaProvider, SchemaWithMeta } from '@contember/engine-system-api'\nimport { filterSchemaByStage, normalizeSchema } from '@contember/schema-utils'\nimport { Schema } from '@contember/schema'\nimport { ContentApiSpecificCache } from './ContentApiSpecificCache'\n\nexport class ContentSchemaResolver {\n\tprivate baseSchemaCache: SchemaWithMeta | null = null\n\n\tconstructor(private readonly schemaProvider: SchemaProvider) {\n\t}\n\n\tpublic clearCache() {\n\t\tthis.baseSchemaCache = null\n\t}\n\n\tpublic async getSchema({ db, stage, normalize }: {\n\t\tdb: DatabaseContext\n\t\tnormalize?: boolean\n\t\tstage?: string\n\t}): Promise<SchemaWithMeta> {\n\t\tconst prevBaseSchema = this.baseSchemaCache\n\t\tthis.baseSchemaCache = await this.schemaProvider.fetch({ db, currentSchema: prevBaseSchema })\n\t\tconst finalSchema = getSchema(this.baseSchemaCache.schema, { stage, normalize })\n\t\treturn {\n\t\t\tschema: finalSchema,\n\t\t\tmeta: this.baseSchemaCache.meta,\n\t\t}\n\t}\n}\n\nconst cache = new ContentApiSpecificCache<Schema, Schema>({})\nconst getSchema = (schema: Schema, options: { stage?: string; normalize?: boolean }) => {\n\tconst cacheKey = [options.stage, options.normalize].join('\\xff')\n\treturn cache.fetch(schema, cacheKey, () => {\n\t\tconst result = schema\n\t\tif (options.normalize) {\n\t\t\treturn normalizeSchema(result)\n\t\t}\n\t\tif (options.stage) {\n\t\t\treturn filterSchemaByStage(result, options.stage)\n\t\t}\n\t\treturn result\n\t})\n}\n"],"names":["ContentApiSpecificCache","normalizeSchema","filterSchemaByStage"],"mappings":";;;;;;;AAKO,MAAM,sBAAsB;AAAA,EAGlC,YAA6B,gBAAgC;AAAhC,SAAA,iBAAA;AAF7B,kBAAA,MAAQ,mBAAyC,IAAA;AAAA,EAAA;AAAA,EAK1C,aAAa;AACnB,SAAK,kBAAkB;AAAA,EAAA;AAAA,EAGxB,MAAa,UAAU,EAAE,IAAI,OAAO,aAIR;AAC3B,UAAM,iBAAiB,KAAK;AACvB,SAAA,kBAAkB,MAAM,KAAK,eAAe,MAAM,EAAE,IAAI,eAAe,gBAAgB;AACtF,UAAA,cAAc,UAAU,KAAK,gBAAgB,QAAQ,EAAE,OAAO,WAAW;AACxE,WAAA;AAAA,MACN,QAAQ;AAAA,MACR,MAAM,KAAK,gBAAgB;AAAA,IAC5B;AAAA,EAAA;AAEF;AAEA,MAAM,QAAQ,IAAIA,wBAAwC,wBAAA,EAAE;AAC5D,MAAM,YAAY,CAAC,QAAgB,YAAqD;AACjF,QAAA,WAAW,CAAC,QAAQ,OAAO,QAAQ,SAAS,EAAE,KAAK,GAAM;AAC/D,SAAO,MAAM,MAAM,QAAQ,UAAU,MAAM;AAC1C,UAAM,SAAS;AACf,QAAI,QAAQ,WAAW;AACtB,aAAOC,YAAAA,gBAAgB,MAAM;AAAA,IAAA;AAE9B,QAAI,QAAQ,OAAO;AACX,aAAAC,gCAAoB,QAAQ,QAAQ,KAAK;AAAA,IAAA;AAE1C,WAAA;AAAA,EAAA,CACP;AACF;;"}
1
+ {"version":3,"file":"ContentSchemaResolver.cjs","sources":["../../../../../packages/engine-http/src/content/ContentSchemaResolver.ts"],"sourcesContent":["import { DatabaseContext, SchemaProvider, SchemaWithMeta } from '@contember/engine-system-api'\nimport { filterSchemaByStage, normalizeSchema } from '@contember/schema-utils'\nimport { Schema } from '@contember/schema'\nimport { ContentApiSpecificCache } from './ContentApiSpecificCache'\n\nexport class ContentSchemaResolver {\n\tprivate baseSchemaCache: SchemaWithMeta | null = null\n\n\tconstructor(private readonly schemaProvider: SchemaProvider) {\n\t}\n\n\tpublic clearCache() {\n\t\tthis.baseSchemaCache = null\n\t}\n\n\tpublic async getSchema({ db, stage, normalize }: {\n\t\tdb: DatabaseContext\n\t\tnormalize?: boolean\n\t\tstage?: string\n\t}): Promise<SchemaWithMeta> {\n\t\tconst prevBaseSchema = this.baseSchemaCache\n\t\tthis.baseSchemaCache = await this.schemaProvider.fetch({ db, currentSchema: prevBaseSchema })\n\t\tconst finalSchema = getSchema(this.baseSchemaCache.schema, { stage, normalize })\n\t\treturn {\n\t\t\tschema: finalSchema,\n\t\t\tmeta: this.baseSchemaCache.meta,\n\t\t}\n\t}\n}\n\nconst cache = new ContentApiSpecificCache<Schema, Schema>({})\nconst getSchema = (schema: Schema, options: { stage?: string; normalize?: boolean }) => {\n\tconst cacheKey = [options.stage, options.normalize].join('\\xff')\n\treturn cache.fetch(schema, cacheKey, () => {\n\t\tlet result = schema\n\t\tif (options.normalize) {\n\t\t\tresult = normalizeSchema(result)\n\t\t}\n\t\tif (options.stage) {\n\t\t\tresult = filterSchemaByStage(result, options.stage)\n\t\t}\n\t\treturn result\n\t})\n}\n"],"names":["ContentApiSpecificCache","normalizeSchema","filterSchemaByStage"],"mappings":";;;;;;;AAKO,MAAM,sBAAsB;AAAA,EAGlC,YAA6B,gBAAgC;AAAhC,SAAA,iBAAA;AAF7B,kBAAA,MAAQ,mBAAyC,IAAA;AAAA,EAAA;AAAA,EAK1C,aAAa;AACnB,SAAK,kBAAkB;AAAA,EAAA;AAAA,EAGxB,MAAa,UAAU,EAAE,IAAI,OAAO,aAIR;AAC3B,UAAM,iBAAiB,KAAK;AACvB,SAAA,kBAAkB,MAAM,KAAK,eAAe,MAAM,EAAE,IAAI,eAAe,gBAAgB;AACtF,UAAA,cAAc,UAAU,KAAK,gBAAgB,QAAQ,EAAE,OAAO,WAAW;AACxE,WAAA;AAAA,MACN,QAAQ;AAAA,MACR,MAAM,KAAK,gBAAgB;AAAA,IAC5B;AAAA,EAAA;AAEF;AAEA,MAAM,QAAQ,IAAIA,wBAAwC,wBAAA,EAAE;AAC5D,MAAM,YAAY,CAAC,QAAgB,YAAqD;AACjF,QAAA,WAAW,CAAC,QAAQ,OAAO,QAAQ,SAAS,EAAE,KAAK,GAAM;AAC/D,SAAO,MAAM,MAAM,QAAQ,UAAU,MAAM;AAC1C,QAAI,SAAS;AACb,QAAI,QAAQ,WAAW;AACtB,eAASC,4BAAgB,MAAM;AAAA,IAAA;AAEhC,QAAI,QAAQ,OAAO;AACT,eAAAC,YAAA,oBAAoB,QAAQ,QAAQ,KAAK;AAAA,IAAA;AAE5C,WAAA;AAAA,EAAA,CACP;AACF;;"}
@@ -25,12 +25,12 @@ const cache = new ContentApiSpecificCache({});
25
25
  const getSchema = (schema, options) => {
26
26
  const cacheKey = [options.stage, options.normalize].join("ÿ");
27
27
  return cache.fetch(schema, cacheKey, () => {
28
- const result = schema;
28
+ let result = schema;
29
29
  if (options.normalize) {
30
- return normalizeSchema(result);
30
+ result = normalizeSchema(result);
31
31
  }
32
32
  if (options.stage) {
33
- return filterSchemaByStage(result, options.stage);
33
+ result = filterSchemaByStage(result, options.stage);
34
34
  }
35
35
  return result;
36
36
  });
@@ -1 +1 @@
1
- {"version":3,"file":"ContentSchemaResolver.js","sources":["../../../../../packages/engine-http/src/content/ContentSchemaResolver.ts"],"sourcesContent":["import { DatabaseContext, SchemaProvider, SchemaWithMeta } from '@contember/engine-system-api'\nimport { filterSchemaByStage, normalizeSchema } from '@contember/schema-utils'\nimport { Schema } from '@contember/schema'\nimport { ContentApiSpecificCache } from './ContentApiSpecificCache'\n\nexport class ContentSchemaResolver {\n\tprivate baseSchemaCache: SchemaWithMeta | null = null\n\n\tconstructor(private readonly schemaProvider: SchemaProvider) {\n\t}\n\n\tpublic clearCache() {\n\t\tthis.baseSchemaCache = null\n\t}\n\n\tpublic async getSchema({ db, stage, normalize }: {\n\t\tdb: DatabaseContext\n\t\tnormalize?: boolean\n\t\tstage?: string\n\t}): Promise<SchemaWithMeta> {\n\t\tconst prevBaseSchema = this.baseSchemaCache\n\t\tthis.baseSchemaCache = await this.schemaProvider.fetch({ db, currentSchema: prevBaseSchema })\n\t\tconst finalSchema = getSchema(this.baseSchemaCache.schema, { stage, normalize })\n\t\treturn {\n\t\t\tschema: finalSchema,\n\t\t\tmeta: this.baseSchemaCache.meta,\n\t\t}\n\t}\n}\n\nconst cache = new ContentApiSpecificCache<Schema, Schema>({})\nconst getSchema = (schema: Schema, options: { stage?: string; normalize?: boolean }) => {\n\tconst cacheKey = [options.stage, options.normalize].join('\\xff')\n\treturn cache.fetch(schema, cacheKey, () => {\n\t\tconst result = schema\n\t\tif (options.normalize) {\n\t\t\treturn normalizeSchema(result)\n\t\t}\n\t\tif (options.stage) {\n\t\t\treturn filterSchemaByStage(result, options.stage)\n\t\t}\n\t\treturn result\n\t})\n}\n"],"names":[],"mappings":";;;;;AAKO,MAAM,sBAAsB;AAAA,EAGlC,YAA6B,gBAAgC;AAAhC,SAAA,iBAAA;AAF7B,kBAAA,MAAQ,mBAAyC,IAAA;AAAA,EAAA;AAAA,EAK1C,aAAa;AACnB,SAAK,kBAAkB;AAAA,EAAA;AAAA,EAGxB,MAAa,UAAU,EAAE,IAAI,OAAO,aAIR;AAC3B,UAAM,iBAAiB,KAAK;AACvB,SAAA,kBAAkB,MAAM,KAAK,eAAe,MAAM,EAAE,IAAI,eAAe,gBAAgB;AACtF,UAAA,cAAc,UAAU,KAAK,gBAAgB,QAAQ,EAAE,OAAO,WAAW;AACxE,WAAA;AAAA,MACN,QAAQ;AAAA,MACR,MAAM,KAAK,gBAAgB;AAAA,IAC5B;AAAA,EAAA;AAEF;AAEA,MAAM,QAAQ,IAAI,wBAAwC,EAAE;AAC5D,MAAM,YAAY,CAAC,QAAgB,YAAqD;AACjF,QAAA,WAAW,CAAC,QAAQ,OAAO,QAAQ,SAAS,EAAE,KAAK,GAAM;AAC/D,SAAO,MAAM,MAAM,QAAQ,UAAU,MAAM;AAC1C,UAAM,SAAS;AACf,QAAI,QAAQ,WAAW;AACtB,aAAO,gBAAgB,MAAM;AAAA,IAAA;AAE9B,QAAI,QAAQ,OAAO;AACX,aAAA,oBAAoB,QAAQ,QAAQ,KAAK;AAAA,IAAA;AAE1C,WAAA;AAAA,EAAA,CACP;AACF;"}
1
+ {"version":3,"file":"ContentSchemaResolver.js","sources":["../../../../../packages/engine-http/src/content/ContentSchemaResolver.ts"],"sourcesContent":["import { DatabaseContext, SchemaProvider, SchemaWithMeta } from '@contember/engine-system-api'\nimport { filterSchemaByStage, normalizeSchema } from '@contember/schema-utils'\nimport { Schema } from '@contember/schema'\nimport { ContentApiSpecificCache } from './ContentApiSpecificCache'\n\nexport class ContentSchemaResolver {\n\tprivate baseSchemaCache: SchemaWithMeta | null = null\n\n\tconstructor(private readonly schemaProvider: SchemaProvider) {\n\t}\n\n\tpublic clearCache() {\n\t\tthis.baseSchemaCache = null\n\t}\n\n\tpublic async getSchema({ db, stage, normalize }: {\n\t\tdb: DatabaseContext\n\t\tnormalize?: boolean\n\t\tstage?: string\n\t}): Promise<SchemaWithMeta> {\n\t\tconst prevBaseSchema = this.baseSchemaCache\n\t\tthis.baseSchemaCache = await this.schemaProvider.fetch({ db, currentSchema: prevBaseSchema })\n\t\tconst finalSchema = getSchema(this.baseSchemaCache.schema, { stage, normalize })\n\t\treturn {\n\t\t\tschema: finalSchema,\n\t\t\tmeta: this.baseSchemaCache.meta,\n\t\t}\n\t}\n}\n\nconst cache = new ContentApiSpecificCache<Schema, Schema>({})\nconst getSchema = (schema: Schema, options: { stage?: string; normalize?: boolean }) => {\n\tconst cacheKey = [options.stage, options.normalize].join('\\xff')\n\treturn cache.fetch(schema, cacheKey, () => {\n\t\tlet result = schema\n\t\tif (options.normalize) {\n\t\t\tresult = normalizeSchema(result)\n\t\t}\n\t\tif (options.stage) {\n\t\t\tresult = filterSchemaByStage(result, options.stage)\n\t\t}\n\t\treturn result\n\t})\n}\n"],"names":[],"mappings":";;;;;AAKO,MAAM,sBAAsB;AAAA,EAGlC,YAA6B,gBAAgC;AAAhC,SAAA,iBAAA;AAF7B,kBAAA,MAAQ,mBAAyC,IAAA;AAAA,EAAA;AAAA,EAK1C,aAAa;AACnB,SAAK,kBAAkB;AAAA,EAAA;AAAA,EAGxB,MAAa,UAAU,EAAE,IAAI,OAAO,aAIR;AAC3B,UAAM,iBAAiB,KAAK;AACvB,SAAA,kBAAkB,MAAM,KAAK,eAAe,MAAM,EAAE,IAAI,eAAe,gBAAgB;AACtF,UAAA,cAAc,UAAU,KAAK,gBAAgB,QAAQ,EAAE,OAAO,WAAW;AACxE,WAAA;AAAA,MACN,QAAQ;AAAA,MACR,MAAM,KAAK,gBAAgB;AAAA,IAC5B;AAAA,EAAA;AAEF;AAEA,MAAM,QAAQ,IAAI,wBAAwC,EAAE;AAC5D,MAAM,YAAY,CAAC,QAAgB,YAAqD;AACjF,QAAA,WAAW,CAAC,QAAQ,OAAO,QAAQ,SAAS,EAAE,KAAK,GAAM;AAC/D,SAAO,MAAM,MAAM,QAAQ,UAAU,MAAM;AAC1C,QAAI,SAAS;AACb,QAAI,QAAQ,WAAW;AACtB,eAAS,gBAAgB,MAAM;AAAA,IAAA;AAEhC,QAAI,QAAQ,OAAO;AACT,eAAA,oBAAoB,QAAQ,QAAQ,KAAK;AAAA,IAAA;AAE5C,WAAA;AAAA,EAAA,CACP;AACF;"}
@@ -27,12 +27,12 @@ const cache = new ContentApiSpecificCache.ContentApiSpecificCache({});
27
27
  const getSchema = (schema, options) => {
28
28
  const cacheKey = [options.stage, options.normalize].join("ÿ");
29
29
  return cache.fetch(schema, cacheKey, () => {
30
- const result = schema;
30
+ let result = schema;
31
31
  if (options.normalize) {
32
- return schemaUtils.normalizeSchema(result);
32
+ result = schemaUtils.normalizeSchema(result);
33
33
  }
34
34
  if (options.stage) {
35
- return schemaUtils.filterSchemaByStage(result, options.stage);
35
+ result = schemaUtils.filterSchemaByStage(result, options.stage);
36
36
  }
37
37
  return result;
38
38
  });
@@ -1 +1 @@
1
- {"version":3,"file":"ContentSchemaResolver.cjs","sources":["../../../../../packages/engine-http/src/content/ContentSchemaResolver.ts"],"sourcesContent":["import { DatabaseContext, SchemaProvider, SchemaWithMeta } from '@contember/engine-system-api'\nimport { filterSchemaByStage, normalizeSchema } from '@contember/schema-utils'\nimport { Schema } from '@contember/schema'\nimport { ContentApiSpecificCache } from './ContentApiSpecificCache'\n\nexport class ContentSchemaResolver {\n\tprivate baseSchemaCache: SchemaWithMeta | null = null\n\n\tconstructor(private readonly schemaProvider: SchemaProvider) {\n\t}\n\n\tpublic clearCache() {\n\t\tthis.baseSchemaCache = null\n\t}\n\n\tpublic async getSchema({ db, stage, normalize }: {\n\t\tdb: DatabaseContext\n\t\tnormalize?: boolean\n\t\tstage?: string\n\t}): Promise<SchemaWithMeta> {\n\t\tconst prevBaseSchema = this.baseSchemaCache\n\t\tthis.baseSchemaCache = await this.schemaProvider.fetch({ db, currentSchema: prevBaseSchema })\n\t\tconst finalSchema = getSchema(this.baseSchemaCache.schema, { stage, normalize })\n\t\treturn {\n\t\t\tschema: finalSchema,\n\t\t\tmeta: this.baseSchemaCache.meta,\n\t\t}\n\t}\n}\n\nconst cache = new ContentApiSpecificCache<Schema, Schema>({})\nconst getSchema = (schema: Schema, options: { stage?: string; normalize?: boolean }) => {\n\tconst cacheKey = [options.stage, options.normalize].join('\\xff')\n\treturn cache.fetch(schema, cacheKey, () => {\n\t\tconst result = schema\n\t\tif (options.normalize) {\n\t\t\treturn normalizeSchema(result)\n\t\t}\n\t\tif (options.stage) {\n\t\t\treturn filterSchemaByStage(result, options.stage)\n\t\t}\n\t\treturn result\n\t})\n}\n"],"names":["ContentApiSpecificCache","normalizeSchema","filterSchemaByStage"],"mappings":";;;;;;;AAKO,MAAM,sBAAsB;AAAA,EAGlC,YAA6B,gBAAgC;AAAhC,SAAA,iBAAA;AAF7B,kBAAA,MAAQ,mBAAyC,IAAA;AAAA,EAAA;AAAA,EAK1C,aAAa;AACnB,SAAK,kBAAkB;AAAA,EAAA;AAAA,EAGxB,MAAa,UAAU,EAAE,IAAI,OAAO,aAIR;AAC3B,UAAM,iBAAiB,KAAK;AACvB,SAAA,kBAAkB,MAAM,KAAK,eAAe,MAAM,EAAE,IAAI,eAAe,gBAAgB;AACtF,UAAA,cAAc,UAAU,KAAK,gBAAgB,QAAQ,EAAE,OAAO,WAAW;AACxE,WAAA;AAAA,MACN,QAAQ;AAAA,MACR,MAAM,KAAK,gBAAgB;AAAA,IAC5B;AAAA,EAAA;AAEF;AAEA,MAAM,QAAQ,IAAIA,wBAAwC,wBAAA,EAAE;AAC5D,MAAM,YAAY,CAAC,QAAgB,YAAqD;AACjF,QAAA,WAAW,CAAC,QAAQ,OAAO,QAAQ,SAAS,EAAE,KAAK,GAAM;AAC/D,SAAO,MAAM,MAAM,QAAQ,UAAU,MAAM;AAC1C,UAAM,SAAS;AACf,QAAI,QAAQ,WAAW;AACtB,aAAOC,YAAAA,gBAAgB,MAAM;AAAA,IAAA;AAE9B,QAAI,QAAQ,OAAO;AACX,aAAAC,gCAAoB,QAAQ,QAAQ,KAAK;AAAA,IAAA;AAE1C,WAAA;AAAA,EAAA,CACP;AACF;;"}
1
+ {"version":3,"file":"ContentSchemaResolver.cjs","sources":["../../../../../packages/engine-http/src/content/ContentSchemaResolver.ts"],"sourcesContent":["import { DatabaseContext, SchemaProvider, SchemaWithMeta } from '@contember/engine-system-api'\nimport { filterSchemaByStage, normalizeSchema } from '@contember/schema-utils'\nimport { Schema } from '@contember/schema'\nimport { ContentApiSpecificCache } from './ContentApiSpecificCache'\n\nexport class ContentSchemaResolver {\n\tprivate baseSchemaCache: SchemaWithMeta | null = null\n\n\tconstructor(private readonly schemaProvider: SchemaProvider) {\n\t}\n\n\tpublic clearCache() {\n\t\tthis.baseSchemaCache = null\n\t}\n\n\tpublic async getSchema({ db, stage, normalize }: {\n\t\tdb: DatabaseContext\n\t\tnormalize?: boolean\n\t\tstage?: string\n\t}): Promise<SchemaWithMeta> {\n\t\tconst prevBaseSchema = this.baseSchemaCache\n\t\tthis.baseSchemaCache = await this.schemaProvider.fetch({ db, currentSchema: prevBaseSchema })\n\t\tconst finalSchema = getSchema(this.baseSchemaCache.schema, { stage, normalize })\n\t\treturn {\n\t\t\tschema: finalSchema,\n\t\t\tmeta: this.baseSchemaCache.meta,\n\t\t}\n\t}\n}\n\nconst cache = new ContentApiSpecificCache<Schema, Schema>({})\nconst getSchema = (schema: Schema, options: { stage?: string; normalize?: boolean }) => {\n\tconst cacheKey = [options.stage, options.normalize].join('\\xff')\n\treturn cache.fetch(schema, cacheKey, () => {\n\t\tlet result = schema\n\t\tif (options.normalize) {\n\t\t\tresult = normalizeSchema(result)\n\t\t}\n\t\tif (options.stage) {\n\t\t\tresult = filterSchemaByStage(result, options.stage)\n\t\t}\n\t\treturn result\n\t})\n}\n"],"names":["ContentApiSpecificCache","normalizeSchema","filterSchemaByStage"],"mappings":";;;;;;;AAKO,MAAM,sBAAsB;AAAA,EAGlC,YAA6B,gBAAgC;AAAhC,SAAA,iBAAA;AAF7B,kBAAA,MAAQ,mBAAyC,IAAA;AAAA,EAAA;AAAA,EAK1C,aAAa;AACnB,SAAK,kBAAkB;AAAA,EAAA;AAAA,EAGxB,MAAa,UAAU,EAAE,IAAI,OAAO,aAIR;AAC3B,UAAM,iBAAiB,KAAK;AACvB,SAAA,kBAAkB,MAAM,KAAK,eAAe,MAAM,EAAE,IAAI,eAAe,gBAAgB;AACtF,UAAA,cAAc,UAAU,KAAK,gBAAgB,QAAQ,EAAE,OAAO,WAAW;AACxE,WAAA;AAAA,MACN,QAAQ;AAAA,MACR,MAAM,KAAK,gBAAgB;AAAA,IAC5B;AAAA,EAAA;AAEF;AAEA,MAAM,QAAQ,IAAIA,wBAAwC,wBAAA,EAAE;AAC5D,MAAM,YAAY,CAAC,QAAgB,YAAqD;AACjF,QAAA,WAAW,CAAC,QAAQ,OAAO,QAAQ,SAAS,EAAE,KAAK,GAAM;AAC/D,SAAO,MAAM,MAAM,QAAQ,UAAU,MAAM;AAC1C,QAAI,SAAS;AACb,QAAI,QAAQ,WAAW;AACtB,eAASC,4BAAgB,MAAM;AAAA,IAAA;AAEhC,QAAI,QAAQ,OAAO;AACT,eAAAC,YAAA,oBAAoB,QAAQ,QAAQ,KAAK;AAAA,IAAA;AAE5C,WAAA;AAAA,EAAA,CACP;AACF;;"}
@@ -25,12 +25,12 @@ const cache = new ContentApiSpecificCache({});
25
25
  const getSchema = (schema, options) => {
26
26
  const cacheKey = [options.stage, options.normalize].join("ÿ");
27
27
  return cache.fetch(schema, cacheKey, () => {
28
- const result = schema;
28
+ let result = schema;
29
29
  if (options.normalize) {
30
- return normalizeSchema(result);
30
+ result = normalizeSchema(result);
31
31
  }
32
32
  if (options.stage) {
33
- return filterSchemaByStage(result, options.stage);
33
+ result = filterSchemaByStage(result, options.stage);
34
34
  }
35
35
  return result;
36
36
  });
@@ -1 +1 @@
1
- {"version":3,"file":"ContentSchemaResolver.js","sources":["../../../../../packages/engine-http/src/content/ContentSchemaResolver.ts"],"sourcesContent":["import { DatabaseContext, SchemaProvider, SchemaWithMeta } from '@contember/engine-system-api'\nimport { filterSchemaByStage, normalizeSchema } from '@contember/schema-utils'\nimport { Schema } from '@contember/schema'\nimport { ContentApiSpecificCache } from './ContentApiSpecificCache'\n\nexport class ContentSchemaResolver {\n\tprivate baseSchemaCache: SchemaWithMeta | null = null\n\n\tconstructor(private readonly schemaProvider: SchemaProvider) {\n\t}\n\n\tpublic clearCache() {\n\t\tthis.baseSchemaCache = null\n\t}\n\n\tpublic async getSchema({ db, stage, normalize }: {\n\t\tdb: DatabaseContext\n\t\tnormalize?: boolean\n\t\tstage?: string\n\t}): Promise<SchemaWithMeta> {\n\t\tconst prevBaseSchema = this.baseSchemaCache\n\t\tthis.baseSchemaCache = await this.schemaProvider.fetch({ db, currentSchema: prevBaseSchema })\n\t\tconst finalSchema = getSchema(this.baseSchemaCache.schema, { stage, normalize })\n\t\treturn {\n\t\t\tschema: finalSchema,\n\t\t\tmeta: this.baseSchemaCache.meta,\n\t\t}\n\t}\n}\n\nconst cache = new ContentApiSpecificCache<Schema, Schema>({})\nconst getSchema = (schema: Schema, options: { stage?: string; normalize?: boolean }) => {\n\tconst cacheKey = [options.stage, options.normalize].join('\\xff')\n\treturn cache.fetch(schema, cacheKey, () => {\n\t\tconst result = schema\n\t\tif (options.normalize) {\n\t\t\treturn normalizeSchema(result)\n\t\t}\n\t\tif (options.stage) {\n\t\t\treturn filterSchemaByStage(result, options.stage)\n\t\t}\n\t\treturn result\n\t})\n}\n"],"names":[],"mappings":";;;;;AAKO,MAAM,sBAAsB;AAAA,EAGlC,YAA6B,gBAAgC;AAAhC,SAAA,iBAAA;AAF7B,kBAAA,MAAQ,mBAAyC,IAAA;AAAA,EAAA;AAAA,EAK1C,aAAa;AACnB,SAAK,kBAAkB;AAAA,EAAA;AAAA,EAGxB,MAAa,UAAU,EAAE,IAAI,OAAO,aAIR;AAC3B,UAAM,iBAAiB,KAAK;AACvB,SAAA,kBAAkB,MAAM,KAAK,eAAe,MAAM,EAAE,IAAI,eAAe,gBAAgB;AACtF,UAAA,cAAc,UAAU,KAAK,gBAAgB,QAAQ,EAAE,OAAO,WAAW;AACxE,WAAA;AAAA,MACN,QAAQ;AAAA,MACR,MAAM,KAAK,gBAAgB;AAAA,IAC5B;AAAA,EAAA;AAEF;AAEA,MAAM,QAAQ,IAAI,wBAAwC,EAAE;AAC5D,MAAM,YAAY,CAAC,QAAgB,YAAqD;AACjF,QAAA,WAAW,CAAC,QAAQ,OAAO,QAAQ,SAAS,EAAE,KAAK,GAAM;AAC/D,SAAO,MAAM,MAAM,QAAQ,UAAU,MAAM;AAC1C,UAAM,SAAS;AACf,QAAI,QAAQ,WAAW;AACtB,aAAO,gBAAgB,MAAM;AAAA,IAAA;AAE9B,QAAI,QAAQ,OAAO;AACX,aAAA,oBAAoB,QAAQ,QAAQ,KAAK;AAAA,IAAA;AAE1C,WAAA;AAAA,EAAA,CACP;AACF;"}
1
+ {"version":3,"file":"ContentSchemaResolver.js","sources":["../../../../../packages/engine-http/src/content/ContentSchemaResolver.ts"],"sourcesContent":["import { DatabaseContext, SchemaProvider, SchemaWithMeta } from '@contember/engine-system-api'\nimport { filterSchemaByStage, normalizeSchema } from '@contember/schema-utils'\nimport { Schema } from '@contember/schema'\nimport { ContentApiSpecificCache } from './ContentApiSpecificCache'\n\nexport class ContentSchemaResolver {\n\tprivate baseSchemaCache: SchemaWithMeta | null = null\n\n\tconstructor(private readonly schemaProvider: SchemaProvider) {\n\t}\n\n\tpublic clearCache() {\n\t\tthis.baseSchemaCache = null\n\t}\n\n\tpublic async getSchema({ db, stage, normalize }: {\n\t\tdb: DatabaseContext\n\t\tnormalize?: boolean\n\t\tstage?: string\n\t}): Promise<SchemaWithMeta> {\n\t\tconst prevBaseSchema = this.baseSchemaCache\n\t\tthis.baseSchemaCache = await this.schemaProvider.fetch({ db, currentSchema: prevBaseSchema })\n\t\tconst finalSchema = getSchema(this.baseSchemaCache.schema, { stage, normalize })\n\t\treturn {\n\t\t\tschema: finalSchema,\n\t\t\tmeta: this.baseSchemaCache.meta,\n\t\t}\n\t}\n}\n\nconst cache = new ContentApiSpecificCache<Schema, Schema>({})\nconst getSchema = (schema: Schema, options: { stage?: string; normalize?: boolean }) => {\n\tconst cacheKey = [options.stage, options.normalize].join('\\xff')\n\treturn cache.fetch(schema, cacheKey, () => {\n\t\tlet result = schema\n\t\tif (options.normalize) {\n\t\t\tresult = normalizeSchema(result)\n\t\t}\n\t\tif (options.stage) {\n\t\t\tresult = filterSchemaByStage(result, options.stage)\n\t\t}\n\t\treturn result\n\t})\n}\n"],"names":[],"mappings":";;;;;AAKO,MAAM,sBAAsB;AAAA,EAGlC,YAA6B,gBAAgC;AAAhC,SAAA,iBAAA;AAF7B,kBAAA,MAAQ,mBAAyC,IAAA;AAAA,EAAA;AAAA,EAK1C,aAAa;AACnB,SAAK,kBAAkB;AAAA,EAAA;AAAA,EAGxB,MAAa,UAAU,EAAE,IAAI,OAAO,aAIR;AAC3B,UAAM,iBAAiB,KAAK;AACvB,SAAA,kBAAkB,MAAM,KAAK,eAAe,MAAM,EAAE,IAAI,eAAe,gBAAgB;AACtF,UAAA,cAAc,UAAU,KAAK,gBAAgB,QAAQ,EAAE,OAAO,WAAW;AACxE,WAAA;AAAA,MACN,QAAQ;AAAA,MACR,MAAM,KAAK,gBAAgB;AAAA,IAC5B;AAAA,EAAA;AAEF;AAEA,MAAM,QAAQ,IAAI,wBAAwC,EAAE;AAC5D,MAAM,YAAY,CAAC,QAAgB,YAAqD;AACjF,QAAA,WAAW,CAAC,QAAQ,OAAO,QAAQ,SAAS,EAAE,KAAK,GAAM;AAC/D,SAAO,MAAM,MAAM,QAAQ,UAAU,MAAM;AAC1C,QAAI,SAAS;AACb,QAAI,QAAQ,WAAW;AACtB,eAAS,gBAAgB,MAAM;AAAA,IAAA;AAEhC,QAAI,QAAQ,OAAO;AACT,eAAA,oBAAoB,QAAQ,QAAQ,KAAK;AAAA,IAAA;AAE5C,WAAA;AAAA,EAAA,CACP;AACF;"}