@webiny/api-headless-cms 5.37.4 → 5.37.5-beta.1
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.
|
@@ -181,12 +181,14 @@ const referenceFieldsMapping = async params => {
|
|
|
181
181
|
/**
|
|
182
182
|
* Load all models and use only those that are used in reference.
|
|
183
183
|
*/
|
|
184
|
-
const models =
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
184
|
+
const models = await context.security.withoutAuthorization(async () => {
|
|
185
|
+
return (await context.cms.listModels()).filter(model => {
|
|
186
|
+
const entries = referencesByModel[model.modelId];
|
|
187
|
+
if (!Array.isArray(entries) || entries.length === 0) {
|
|
188
|
+
return false;
|
|
189
|
+
}
|
|
190
|
+
return true;
|
|
191
|
+
});
|
|
190
192
|
});
|
|
191
193
|
/**
|
|
192
194
|
* Check for any model existence, just in case.
|
|
@@ -198,8 +200,10 @@ const referenceFieldsMapping = async params => {
|
|
|
198
200
|
/**
|
|
199
201
|
* Load all the entries by their ID
|
|
200
202
|
*/
|
|
201
|
-
const promises =
|
|
202
|
-
return
|
|
203
|
+
const promises = await context.security.withoutAuthorization(async () => {
|
|
204
|
+
return models.map(model => {
|
|
205
|
+
return context.cms.getEntriesByIds(model, referencesByModel[model.modelId]);
|
|
206
|
+
});
|
|
203
207
|
});
|
|
204
208
|
const results = await Promise.all(promises);
|
|
205
209
|
const records = results.reduce((collection, entries) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_error","_interopRequireDefault","require","_dotProp","_utils","_getBaseFieldType","buildReferenceFieldPaths","params","fields","parentPaths","initialParentPaths","input","isMultipleValues","Array","isArray","filter","field","includes","getBaseFieldType","reduce","collection","_field$settings3","baseType","parentPathsValue","length","join","multipleValues","inputValue","dotProp","get","fieldId","key","path","push","_field$settings","templates","settings","template","result","concat","gqlTypeName","objFieldPath","objFieldInputValue","_field$settings2","results","getReferenceFieldValue","ref","id","modelId","entryId","trim","referenceFieldsMapping","context","model","validateEntries","output","_objectSpread2","default","referenceFieldPaths","referencesByModel","pathsByReferenceId","Object","keys","models","cms","listModels","entries","promises","map","getEntriesByIds","Promise","all","records","entry","WebinyError","parseIdentifier","paths","set","exports"],"sources":["referenceFieldsMapping.ts"],"sourcesContent":["import { CmsContext, CmsDynamicZoneTemplate, CmsModel, CmsModelField } from \"~/types\";\nimport WebinyError from \"@webiny/error\";\nimport dotProp from \"dot-prop\";\nimport { parseIdentifier } from \"@webiny/utils\";\nimport { getBaseFieldType } from \"~/utils/getBaseFieldType\";\n\ninterface CmsRefEntry {\n id: string;\n entryId: string;\n modelId: string;\n}\n\ninterface ReferenceObject {\n id: string;\n modelId: string;\n}\n\ninterface Params {\n context: CmsContext;\n model: CmsModel;\n input: Record<string, ReferenceObject | ReferenceObject[]>;\n validateEntries?: boolean;\n}\n\ninterface BuildReferenceFieldPaths {\n fields: CmsModelField[];\n parentPaths: string[];\n input: Record<string, any>;\n}\n\nconst buildReferenceFieldPaths = (params: BuildReferenceFieldPaths): string[] => {\n const { fields, parentPaths: initialParentPaths, input } = params;\n\n const parentPaths = [...initialParentPaths];\n\n const isMultipleValues = Array.isArray(input);\n\n return fields\n .filter(field => [\"object\", \"ref\", \"dynamicZone\"].includes(getBaseFieldType(field)))\n .reduce((collection, field) => {\n /**\n * First we check the ref field\n */\n const baseType = getBaseFieldType(field);\n if (baseType === \"ref\") {\n const parentPathsValue = parentPaths.length > 0 ? `${parentPaths.join(\".\")}.` : \"\";\n if (field.multipleValues) {\n const inputValue = dotProp.get(input, `${field.fieldId}`, []);\n if (Array.isArray(inputValue) === false) {\n return collection;\n }\n for (const key in inputValue) {\n const path = `${parentPathsValue}${field.fieldId}.${key}`;\n collection.push(path);\n }\n return collection;\n }\n\n if (isMultipleValues) {\n for (const key in input) {\n const path = `${parentPathsValue}${key}.${field.fieldId}`;\n collection.push(path);\n }\n return collection;\n }\n\n collection.push(`${parentPathsValue}${field.fieldId}`);\n\n return collection;\n }\n\n if (baseType === \"dynamicZone\") {\n const templates: CmsDynamicZoneTemplate[] = field.settings?.templates || [];\n for (const template of templates) {\n if (field.multipleValues) {\n const inputValue = dotProp.get(input, `${field.fieldId}`, []);\n if (Array.isArray(inputValue) === false) {\n return collection;\n }\n\n for (const key in inputValue) {\n const result = buildReferenceFieldPaths({\n fields: template.fields,\n input: inputValue[key],\n parentPaths: parentPaths.concat([\n field.fieldId,\n key,\n template.gqlTypeName\n ])\n });\n collection.push(...result);\n }\n continue;\n }\n\n const result = buildReferenceFieldPaths({\n fields: template.fields,\n input,\n parentPaths: parentPaths.concat([field.fieldId, template.gqlTypeName])\n });\n collection.push(...result);\n }\n\n return collection;\n }\n\n /**\n * Then we move onto the object field\n */\n const parentPathsValue = parentPaths.length > 0 ? `${parentPaths.join(\".\")}.` : \"\";\n /**\n * This is if received input is array. We need to map key with fieldId at this point.\n */\n if (isMultipleValues) {\n for (const key in input) {\n const path = `${parentPathsValue}${key}.${field.fieldId}`;\n collection.push(path);\n }\n return collection;\n }\n\n const objFieldPath = `${field.fieldId}`;\n const objFieldInputValue = dotProp.get(input, objFieldPath, []);\n\n /**\n * If field is multiple values one, we need to go through the input and use the existing keys.\n */\n if (field.multipleValues) {\n if (Array.isArray(objFieldInputValue) === false) {\n return collection;\n }\n for (const key in objFieldInputValue) {\n const result = buildReferenceFieldPaths({\n fields: field.settings?.fields || [],\n input: objFieldInputValue[key],\n parentPaths: parentPaths.concat([field.fieldId, key])\n });\n collection.push(...result);\n }\n\n return collection;\n }\n\n /**\n * Single value reference field.\n */\n const results = buildReferenceFieldPaths({\n fields: field.settings?.fields || [],\n input: objFieldInputValue,\n parentPaths: parentPaths.concat([field.fieldId])\n });\n\n return collection.concat(results);\n }, [] as string[]);\n};\n\nconst getReferenceFieldValue = (ref: any): { id: string | null; modelId: string | null } => {\n if (!ref) {\n return {\n id: null,\n modelId: null\n };\n }\n return {\n id: (ref.id || ref.entryId || \"\").trim() || null,\n modelId: (ref.modelId || \"\").trim() || null\n };\n};\n\nexport const referenceFieldsMapping = async (params: Params): Promise<Record<string, any>> => {\n const { context, model, input, validateEntries = false } = params;\n\n let output: Record<string, any> = {\n ...input\n };\n\n const referenceFieldPaths = buildReferenceFieldPaths({\n fields: model.fields,\n input,\n parentPaths: []\n });\n if (referenceFieldPaths.length === 0) {\n return output;\n }\n\n const referencesByModel: Record<string, string[]> = {};\n const pathsByReferenceId: Record<string, string[]> = {};\n\n for (const path of referenceFieldPaths) {\n const ref = dotProp.get(output, path) as ReferenceObject | any;\n\n const { id, modelId } = getReferenceFieldValue(ref);\n\n if (!id || !modelId) {\n continue;\n }\n if (!referencesByModel[modelId]) {\n referencesByModel[modelId] = [];\n }\n referencesByModel[modelId].push(id);\n if (!pathsByReferenceId[id]) {\n pathsByReferenceId[id] = [];\n }\n pathsByReferenceId[id].push(path);\n }\n\n /**\n * Again, no point in going further.\n */\n if (Object.keys(referencesByModel).length === 0) {\n return output;\n }\n /**\n * Load all models and use only those that are used in reference.\n */\n const models = (await context.cms.listModels()).filter(model => {\n const entries = referencesByModel[model.modelId];\n if (!Array.isArray(entries) || entries.length === 0) {\n return false;\n }\n return true;\n });\n /**\n * Check for any model existence, just in case.\n */\n if (models.length === 0) {\n return output;\n }\n\n /**\n * Load all the entries by their ID\n */\n const promises = models.map(model => {\n return context.cms.getEntriesByIds(model, referencesByModel[model.modelId]);\n });\n\n const results = await Promise.all(promises);\n\n const records: Record<string, CmsRefEntry> = results.reduce((collection, entries) => {\n for (const entry of entries) {\n collection[entry.id] = {\n id: entry.id,\n entryId: entry.entryId,\n modelId: entry.modelId\n };\n }\n return collection;\n }, {} as Record<string, CmsRefEntry>);\n /**\n * Verify that all referenced entries actually exist.\n */\n for (const modelId in referencesByModel) {\n const entries = referencesByModel[modelId];\n for (const id of entries) {\n if (records[id]) {\n continue;\n } else if (validateEntries) {\n throw new WebinyError(\n `Missing referenced entry with id \"${id}\" in model \"${modelId}\".`,\n \"ENTRY_NOT_FOUND\",\n {\n id,\n model: modelId\n }\n );\n }\n const { id: entryId } = parseIdentifier(id);\n records[id] = {\n id,\n entryId,\n modelId\n };\n }\n }\n\n /**\n * In the end, assign the entryId, id and model values to the output.\n */\n for (const id in pathsByReferenceId) {\n const entry = records[id];\n const paths = pathsByReferenceId[id];\n if (!entry) {\n if (validateEntries) {\n throw new WebinyError(\"Missing entry in records.\", \"ENTRY_ERROR\", {\n id,\n paths\n });\n }\n continue;\n }\n for (const path of paths) {\n output = dotProp.set(output, path, {\n id: entry.id,\n entryId: entry.entryId,\n modelId: entry.modelId\n });\n }\n }\n\n return output;\n};\n"],"mappings":";;;;;;;;AACA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,QAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,iBAAA,GAAAH,OAAA;AA0BA,MAAMI,wBAAwB,GAAIC,MAAgC,IAAe;EAC7E,MAAM;IAAEC,MAAM;IAAEC,WAAW,EAAEC,kBAAkB;IAAEC;EAAM,CAAC,GAAGJ,MAAM;EAEjE,MAAME,WAAW,GAAG,CAAC,GAAGC,kBAAkB,CAAC;EAE3C,MAAME,gBAAgB,GAAGC,KAAK,CAACC,OAAO,CAACH,KAAK,CAAC;EAE7C,OAAOH,MAAM,CACRO,MAAM,CAACC,KAAK,IAAI,CAAC,QAAQ,EAAE,KAAK,EAAE,aAAa,CAAC,CAACC,QAAQ,CAAC,IAAAC,kCAAgB,EAACF,KAAK,CAAC,CAAC,CAAC,CACnFG,MAAM,CAAC,CAACC,UAAU,EAAEJ,KAAK,KAAK;IAAA,IAAAK,gBAAA;IAC3B;AACZ;AACA;IACY,MAAMC,QAAQ,GAAG,IAAAJ,kCAAgB,EAACF,KAAK,CAAC;IACxC,IAAIM,QAAQ,KAAK,KAAK,EAAE;MACpB,MAAMC,gBAAgB,GAAGd,WAAW,CAACe,MAAM,GAAG,CAAC,GAAI,GAAE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E,EAAE0B,KAAK,CAAC1B,EAAE;QACZE,OAAO,EAAEwB,KAAK,CAACxB,OAAO;QACtBD,OAAO,EAAEyB,KAAK,CAACzB;MACnB,CAAC,CAAC;IACN;EACJ;EAEA,OAAOO,MAAM;AACjB,CAAC;AAACuB,OAAA,CAAA3B,sBAAA,GAAAA,sBAAA"}
|
|
1
|
+
{"version":3,"names":["_error","_interopRequireDefault","require","_dotProp","_utils","_getBaseFieldType","buildReferenceFieldPaths","params","fields","parentPaths","initialParentPaths","input","isMultipleValues","Array","isArray","filter","field","includes","getBaseFieldType","reduce","collection","_field$settings3","baseType","parentPathsValue","length","join","multipleValues","inputValue","dotProp","get","fieldId","key","path","push","_field$settings","templates","settings","template","result","concat","gqlTypeName","objFieldPath","objFieldInputValue","_field$settings2","results","getReferenceFieldValue","ref","id","modelId","entryId","trim","referenceFieldsMapping","context","model","validateEntries","output","_objectSpread2","default","referenceFieldPaths","referencesByModel","pathsByReferenceId","Object","keys","models","security","withoutAuthorization","cms","listModels","entries","promises","map","getEntriesByIds","Promise","all","records","entry","WebinyError","parseIdentifier","paths","set","exports"],"sources":["referenceFieldsMapping.ts"],"sourcesContent":["import { CmsContext, CmsDynamicZoneTemplate, CmsModel, CmsModelField } from \"~/types\";\nimport WebinyError from \"@webiny/error\";\nimport dotProp from \"dot-prop\";\nimport { parseIdentifier } from \"@webiny/utils\";\nimport { getBaseFieldType } from \"~/utils/getBaseFieldType\";\n\ninterface CmsRefEntry {\n id: string;\n entryId: string;\n modelId: string;\n}\n\ninterface ReferenceObject {\n id: string;\n modelId: string;\n}\n\ninterface Params {\n context: CmsContext;\n model: CmsModel;\n input: Record<string, ReferenceObject | ReferenceObject[]>;\n validateEntries?: boolean;\n}\n\ninterface BuildReferenceFieldPaths {\n fields: CmsModelField[];\n parentPaths: string[];\n input: Record<string, any>;\n}\n\nconst buildReferenceFieldPaths = (params: BuildReferenceFieldPaths): string[] => {\n const { fields, parentPaths: initialParentPaths, input } = params;\n\n const parentPaths = [...initialParentPaths];\n\n const isMultipleValues = Array.isArray(input);\n\n return fields\n .filter(field => [\"object\", \"ref\", \"dynamicZone\"].includes(getBaseFieldType(field)))\n .reduce((collection, field) => {\n /**\n * First we check the ref field\n */\n const baseType = getBaseFieldType(field);\n if (baseType === \"ref\") {\n const parentPathsValue = parentPaths.length > 0 ? `${parentPaths.join(\".\")}.` : \"\";\n if (field.multipleValues) {\n const inputValue = dotProp.get(input, `${field.fieldId}`, []);\n if (Array.isArray(inputValue) === false) {\n return collection;\n }\n for (const key in inputValue) {\n const path = `${parentPathsValue}${field.fieldId}.${key}`;\n collection.push(path);\n }\n return collection;\n }\n\n if (isMultipleValues) {\n for (const key in input) {\n const path = `${parentPathsValue}${key}.${field.fieldId}`;\n collection.push(path);\n }\n return collection;\n }\n\n collection.push(`${parentPathsValue}${field.fieldId}`);\n\n return collection;\n }\n\n if (baseType === \"dynamicZone\") {\n const templates: CmsDynamicZoneTemplate[] = field.settings?.templates || [];\n for (const template of templates) {\n if (field.multipleValues) {\n const inputValue = dotProp.get(input, `${field.fieldId}`, []);\n if (Array.isArray(inputValue) === false) {\n return collection;\n }\n\n for (const key in inputValue) {\n const result = buildReferenceFieldPaths({\n fields: template.fields,\n input: inputValue[key],\n parentPaths: parentPaths.concat([\n field.fieldId,\n key,\n template.gqlTypeName\n ])\n });\n collection.push(...result);\n }\n continue;\n }\n\n const result = buildReferenceFieldPaths({\n fields: template.fields,\n input,\n parentPaths: parentPaths.concat([field.fieldId, template.gqlTypeName])\n });\n collection.push(...result);\n }\n\n return collection;\n }\n\n /**\n * Then we move onto the object field\n */\n const parentPathsValue = parentPaths.length > 0 ? `${parentPaths.join(\".\")}.` : \"\";\n /**\n * This is if received input is array. We need to map key with fieldId at this point.\n */\n if (isMultipleValues) {\n for (const key in input) {\n const path = `${parentPathsValue}${key}.${field.fieldId}`;\n collection.push(path);\n }\n return collection;\n }\n\n const objFieldPath = `${field.fieldId}`;\n const objFieldInputValue = dotProp.get(input, objFieldPath, []);\n\n /**\n * If field is multiple values one, we need to go through the input and use the existing keys.\n */\n if (field.multipleValues) {\n if (Array.isArray(objFieldInputValue) === false) {\n return collection;\n }\n for (const key in objFieldInputValue) {\n const result = buildReferenceFieldPaths({\n fields: field.settings?.fields || [],\n input: objFieldInputValue[key],\n parentPaths: parentPaths.concat([field.fieldId, key])\n });\n collection.push(...result);\n }\n\n return collection;\n }\n\n /**\n * Single value reference field.\n */\n const results = buildReferenceFieldPaths({\n fields: field.settings?.fields || [],\n input: objFieldInputValue,\n parentPaths: parentPaths.concat([field.fieldId])\n });\n\n return collection.concat(results);\n }, [] as string[]);\n};\n\nconst getReferenceFieldValue = (ref: any): { id: string | null; modelId: string | null } => {\n if (!ref) {\n return {\n id: null,\n modelId: null\n };\n }\n return {\n id: (ref.id || ref.entryId || \"\").trim() || null,\n modelId: (ref.modelId || \"\").trim() || null\n };\n};\n\nexport const referenceFieldsMapping = async (params: Params): Promise<Record<string, any>> => {\n const { context, model, input, validateEntries = false } = params;\n\n let output: Record<string, any> = {\n ...input\n };\n\n const referenceFieldPaths = buildReferenceFieldPaths({\n fields: model.fields,\n input,\n parentPaths: []\n });\n if (referenceFieldPaths.length === 0) {\n return output;\n }\n\n const referencesByModel: Record<string, string[]> = {};\n const pathsByReferenceId: Record<string, string[]> = {};\n\n for (const path of referenceFieldPaths) {\n const ref = dotProp.get(output, path) as ReferenceObject | any;\n\n const { id, modelId } = getReferenceFieldValue(ref);\n\n if (!id || !modelId) {\n continue;\n }\n if (!referencesByModel[modelId]) {\n referencesByModel[modelId] = [];\n }\n referencesByModel[modelId].push(id);\n if (!pathsByReferenceId[id]) {\n pathsByReferenceId[id] = [];\n }\n pathsByReferenceId[id].push(path);\n }\n\n /**\n * Again, no point in going further.\n */\n if (Object.keys(referencesByModel).length === 0) {\n return output;\n }\n /**\n * Load all models and use only those that are used in reference.\n */\n const models = await context.security.withoutAuthorization(async () => {\n return (await context.cms.listModels()).filter(model => {\n const entries = referencesByModel[model.modelId];\n if (!Array.isArray(entries) || entries.length === 0) {\n return false;\n }\n return true;\n });\n });\n /**\n * Check for any model existence, just in case.\n */\n if (models.length === 0) {\n return output;\n }\n\n /**\n * Load all the entries by their ID\n */\n const promises = await context.security.withoutAuthorization(async () => {\n return models.map(model => {\n return context.cms.getEntriesByIds(model, referencesByModel[model.modelId]);\n });\n });\n\n const results = await Promise.all(promises);\n\n const records: Record<string, CmsRefEntry> = results.reduce((collection, entries) => {\n for (const entry of entries) {\n collection[entry.id] = {\n id: entry.id,\n entryId: entry.entryId,\n modelId: entry.modelId\n };\n }\n return collection;\n }, {} as Record<string, CmsRefEntry>);\n /**\n * Verify that all referenced entries actually exist.\n */\n for (const modelId in referencesByModel) {\n const entries = referencesByModel[modelId];\n for (const id of entries) {\n if (records[id]) {\n continue;\n } else if (validateEntries) {\n throw new WebinyError(\n `Missing referenced entry with id \"${id}\" in model \"${modelId}\".`,\n \"ENTRY_NOT_FOUND\",\n {\n id,\n model: modelId\n }\n );\n }\n const { id: entryId } = parseIdentifier(id);\n records[id] = {\n id,\n entryId,\n modelId\n };\n }\n }\n\n /**\n * In the end, assign the entryId, id and model values to the output.\n */\n for (const id in pathsByReferenceId) {\n const entry = records[id];\n const paths = pathsByReferenceId[id];\n if (!entry) {\n if (validateEntries) {\n throw new WebinyError(\"Missing entry in records.\", \"ENTRY_ERROR\", {\n id,\n paths\n });\n }\n continue;\n }\n for (const path of paths) {\n output = dotProp.set(output, path, {\n id: entry.id,\n entryId: entry.entryId,\n modelId: entry.modelId\n });\n }\n }\n\n return output;\n};\n"],"mappings":";;;;;;;;AACA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,QAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,iBAAA,GAAAH,OAAA;AA0BA,MAAMI,wBAAwB,GAAIC,MAAgC,IAAe;EAC7E,MAAM;IAAEC,MAAM;IAAEC,WAAW,EAAEC,kBA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,OAAQ,IAAG,EACjE,iBAAiB,EACjB;UACID,EAAE;UACFM,KAAK,EAAEL;QACX,CACJ,CAAC;MACL;MACA,MAAM;QAAED,EAAE,EAAEE;MAAQ,CAAC,GAAG,IAAA4B,sBAAe,EAAC9B,EAAE,CAAC;MAC3C2B,OAAO,CAAC3B,EAAE,CAAC,GAAG;QACVA,EAAE;QACFE,OAAO;QACPD;MACJ,CAAC;IACL;EACJ;;EAEA;AACJ;AACA;EACI,KAAK,MAAMD,EAAE,IAAIa,kBAAkB,EAAE;IACjC,MAAMe,KAAK,GAAGD,OAAO,CAAC3B,EAAE,CAAC;IACzB,MAAM+B,KAAK,GAAGlB,kBAAkB,CAACb,EAAE,CAAC;IACpC,IAAI,CAAC4B,KAAK,EAAE;MACR,IAAIrB,eAAe,EAAE;QACjB,MAAM,IAAIsB,cAAW,CAAC,2BAA2B,EAAE,aAAa,EAAE;UAC9D7B,EAAE;UACF+B;QACJ,CAAC,CAAC;MACN;MACA;IACJ;IACA,KAAK,MAAM9C,IAAI,IAAI8C,KAAK,EAAE;MACtBvB,MAAM,GAAG3B,gBAAO,CAACmD,GAAG,CAACxB,MAAM,EAAEvB,IAAI,EAAE;QAC/Be,EAAE,EAAE4B,KAAK,CAAC5B,EAAE;QACZE,OAAO,EAAE0B,KAAK,CAAC1B,OAAO;QACtBD,OAAO,EAAE2B,KAAK,CAAC3B;MACnB,CAAC,CAAC;IACN;EACJ;EAEA,OAAOO,MAAM;AACjB,CAAC;AAACyB,OAAA,CAAA7B,sBAAA,GAAAA,sBAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/api-headless-cms",
|
|
3
|
-
"version": "5.37.
|
|
3
|
+
"version": "5.37.5-beta.1",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cms:base"
|
|
@@ -20,19 +20,19 @@
|
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"@babel/runtime": "7.22.6",
|
|
22
22
|
"@graphql-tools/schema": "7.1.5",
|
|
23
|
-
"@webiny/api": "5.37.
|
|
24
|
-
"@webiny/api-i18n": "5.37.
|
|
25
|
-
"@webiny/api-security": "5.37.
|
|
26
|
-
"@webiny/api-tenancy": "5.37.
|
|
27
|
-
"@webiny/error": "5.37.
|
|
28
|
-
"@webiny/handler": "5.37.
|
|
29
|
-
"@webiny/handler-aws": "5.37.
|
|
30
|
-
"@webiny/handler-db": "5.37.
|
|
31
|
-
"@webiny/handler-graphql": "5.37.
|
|
32
|
-
"@webiny/plugins": "5.37.
|
|
33
|
-
"@webiny/pubsub": "5.37.
|
|
34
|
-
"@webiny/utils": "5.37.
|
|
35
|
-
"@webiny/validation": "5.37.
|
|
23
|
+
"@webiny/api": "5.37.5-beta.1",
|
|
24
|
+
"@webiny/api-i18n": "5.37.5-beta.1",
|
|
25
|
+
"@webiny/api-security": "5.37.5-beta.1",
|
|
26
|
+
"@webiny/api-tenancy": "5.37.5-beta.1",
|
|
27
|
+
"@webiny/error": "5.37.5-beta.1",
|
|
28
|
+
"@webiny/handler": "5.37.5-beta.1",
|
|
29
|
+
"@webiny/handler-aws": "5.37.5-beta.1",
|
|
30
|
+
"@webiny/handler-db": "5.37.5-beta.1",
|
|
31
|
+
"@webiny/handler-graphql": "5.37.5-beta.1",
|
|
32
|
+
"@webiny/plugins": "5.37.5-beta.1",
|
|
33
|
+
"@webiny/pubsub": "5.37.5-beta.1",
|
|
34
|
+
"@webiny/utils": "5.37.5-beta.1",
|
|
35
|
+
"@webiny/validation": "5.37.5-beta.1",
|
|
36
36
|
"code-frame": "5.0.0",
|
|
37
37
|
"dataloader": "2.2.1",
|
|
38
38
|
"dot-prop": "6.0.1",
|
|
@@ -49,9 +49,9 @@
|
|
|
49
49
|
"@babel/cli": "7.22.6",
|
|
50
50
|
"@babel/core": "7.22.8",
|
|
51
51
|
"@babel/preset-env": "7.22.7",
|
|
52
|
-
"@webiny/api-wcp": "5.37.
|
|
53
|
-
"@webiny/cli": "5.37.
|
|
54
|
-
"@webiny/project-utils": "5.37.
|
|
52
|
+
"@webiny/api-wcp": "5.37.5-beta.1",
|
|
53
|
+
"@webiny/cli": "5.37.5-beta.1",
|
|
54
|
+
"@webiny/project-utils": "5.37.5-beta.1",
|
|
55
55
|
"apollo-graphql": "0.9.7",
|
|
56
56
|
"get-yarn-workspaces": "1.0.2",
|
|
57
57
|
"graphql": "15.8.0",
|
|
@@ -71,5 +71,5 @@
|
|
|
71
71
|
"build": "yarn webiny run build",
|
|
72
72
|
"watch": "yarn webiny run watch"
|
|
73
73
|
},
|
|
74
|
-
"gitHead": "
|
|
74
|
+
"gitHead": "88829ab0c5d875491d6b260f184b7b7fe3a6d449"
|
|
75
75
|
}
|