@webiny/api-headless-cms 6.0.0-rc.3 → 6.0.0-rc.5

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.
@@ -43,7 +43,11 @@ const buildSearchableFieldList = params => {
43
43
  const path = [...parents, field.fieldId].join(".");
44
44
  result.push(path);
45
45
  return result;
46
- }, []);
46
+ },
47
+ /**
48
+ * We always add id and entry id
49
+ */
50
+ ["id", "entryId"]);
47
51
  };
48
52
  export const getSearchableFields = params => {
49
53
  const {
@@ -59,7 +63,7 @@ export const getSearchableFields = params => {
59
63
  fields,
60
64
  input,
61
65
  plugins: fieldPluginMap,
62
- parents: []
66
+ parents: ["values"]
63
67
  });
64
68
  };
65
69
 
@@ -1 +1 @@
1
- {"version":3,"names":["buildSearchableFieldList","params","input","plugins","fields","parents","reduce","result","field","plugin","type","childFields","settings","length","childResults","fieldId","push","fullTextSearch","disableFullTextSearch","path","join","getSearchableFields","fieldPluginMap","byType","collection","fieldType"],"sources":["searchableFields.ts"],"sourcesContent":["import type { CmsModelField, CmsModelFieldToGraphQLPlugin } from \"~/types/index.js\";\nimport type { PluginsContainer } from \"@webiny/plugins\";\n\ninterface BuildParams {\n input: string[];\n fields: CmsModelField[];\n plugins: Record<string, CmsModelFieldToGraphQLPlugin>;\n parents: string[];\n}\nconst buildSearchableFieldList = (params: BuildParams): string[] => {\n const { input, plugins, fields, parents } = params;\n return fields.reduce<string[]>((result, field) => {\n /**\n * We need to check if the field is full text searchable, and for that we need a plugin for the field type.\n */\n const plugin = plugins[field.type];\n if (!plugin) {\n return result;\n }\n /**\n * There is a possibility that searchable fields exist in nested object field, so check that as well.\n */\n const childFields = field.settings?.fields || [];\n if (childFields.length > 0) {\n /**\n * So we build a list of searchable child fields and push it into the main result set.\n */\n const childResults = buildSearchableFieldList({\n fields: childFields,\n parents: [...parents, field.fieldId],\n plugins,\n input\n });\n\n result.push(...childResults);\n return result;\n }\n /**\n * If not searchable, continue further.\n */\n if (!plugin.fullTextSearch || field.settings?.disableFullTextSearch === true) {\n return result;\n }\n\n /**\n * Combine all parent paths with the current one and push it.\n */\n const path = [...parents, field.fieldId].join(\".\");\n result.push(path);\n\n return result;\n }, []);\n};\n\ninterface Params {\n input: string[];\n fields: CmsModelField[];\n plugins: PluginsContainer;\n}\nexport const getSearchableFields = (params: Params): string[] => {\n const { plugins, input, fields } = params;\n const fieldPluginMap = plugins\n .byType<CmsModelFieldToGraphQLPlugin>(\"cms-model-field-to-graphql\")\n .reduce(\n (collection, field) => {\n collection[field.fieldType] = field;\n return collection;\n },\n {} as Record<string, CmsModelFieldToGraphQLPlugin>\n );\n\n return buildSearchableFieldList({\n fields,\n input,\n plugins: fieldPluginMap,\n parents: []\n });\n};\n"],"mappings":"AASA,MAAMA,wBAAwB,GAAIC,MAAmB,IAAe;EAChE,MAAM;IAAEC,KAAK;IAAEC,OAAO;IAAEC,MAAM;IAAEC;EAAQ,CAAC,GAAGJ,MAAM;EAClD,OAAOG,MAAM,CAACE,MAAM,CAAW,CAACC,MAAM,EAAEC,KAAK,KAAK;IAC9C;AACR;AACA;IACQ,MAAMC,MAAM,GAAGN,OAAO,CAACK,KAAK,CAACE,IAAI,CAAC;IAClC,IAAI,CAACD,MAAM,EAAE;MACT,OAAOF,MAAM;IACjB;IACA;AACR;AACA;IACQ,MAAMI,WAAW,GAAGH,KAAK,CAACI,QAAQ,EAAER,MAAM,IAAI,EAAE;IAChD,IAAIO,WAAW,CAACE,MAAM,GAAG,CAAC,EAAE;MACxB;AACZ;AACA;MACY,MAAMC,YAAY,GAAGd,wBAAwB,CAAC;QAC1CI,MAAM,EAAEO,WAAW;QACnBN,OAAO,EAAE,CAAC,GAAGA,OAAO,EAAEG,KAAK,CAACO,OAAO,CAAC;QACpCZ,OAAO;QACPD;MACJ,CAAC,CAAC;MAEFK,MAAM,CAACS,IAAI,CAAC,GAAGF,YAAY,CAAC;MAC5B,OAAOP,MAAM;IACjB;IACA;AACR;AACA;IACQ,IAAI,CAACE,MAAM,CAACQ,cAAc,IAAIT,KAAK,CAACI,QAAQ,EAAEM,qBAAqB,KAAK,IAAI,EAAE;MAC1E,OAAOX,MAAM;IACjB;;IAEA;AACR;AACA;IACQ,MAAMY,IAAI,GAAG,CAAC,GAAGd,OAAO,EAAEG,KAAK,CAACO,OAAO,CAAC,CAACK,IAAI,CAAC,GAAG,CAAC;IAClDb,MAAM,CAACS,IAAI,CAACG,IAAI,CAAC;IAEjB,OAAOZ,MAAM;EACjB,CAAC,EAAE,EAAE,CAAC;AACV,CAAC;AAOD,OAAO,MAAMc,mBAAmB,GAAIpB,MAAc,IAAe;EAC7D,MAAM;IAAEE,OAAO;IAAED,KAAK;IAAEE;EAAO,CAAC,GAAGH,MAAM;EACzC,MAAMqB,cAAc,GAAGnB,OAAO,CACzBoB,MAAM,CAA+B,4BAA4B,CAAC,CAClEjB,MAAM,CACH,CAACkB,UAAU,EAAEhB,KAAK,KAAK;IACnBgB,UAAU,CAAChB,KAAK,CAACiB,SAAS,CAAC,GAAGjB,KAAK;IACnC,OAAOgB,UAAU;EACrB,CAAC,EACD,CAAC,CACL,CAAC;EAEL,OAAOxB,wBAAwB,CAAC;IAC5BI,MAAM;IACNF,KAAK;IACLC,OAAO,EAAEmB,cAAc;IACvBjB,OAAO,EAAE;EACb,CAAC,CAAC;AACN,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["buildSearchableFieldList","params","input","plugins","fields","parents","reduce","result","field","plugin","type","childFields","settings","length","childResults","fieldId","push","fullTextSearch","disableFullTextSearch","path","join","getSearchableFields","fieldPluginMap","byType","collection","fieldType"],"sources":["searchableFields.ts"],"sourcesContent":["import type { CmsModelField, CmsModelFieldToGraphQLPlugin } from \"~/types/index.js\";\nimport type { PluginsContainer } from \"@webiny/plugins\";\n\ninterface BuildParams {\n input: string[];\n fields: CmsModelField[];\n plugins: Record<string, CmsModelFieldToGraphQLPlugin>;\n parents: string[];\n}\nconst buildSearchableFieldList = (params: BuildParams): string[] => {\n const { input, plugins, fields, parents } = params;\n return fields.reduce<string[]>(\n (result, field) => {\n /**\n * We need to check if the field is full text searchable, and for that we need a plugin for the field type.\n */\n const plugin = plugins[field.type];\n if (!plugin) {\n return result;\n }\n /**\n * There is a possibility that searchable fields exist in nested object field, so check that as well.\n */\n const childFields = field.settings?.fields || [];\n if (childFields.length > 0) {\n /**\n * So we build a list of searchable child fields and push it into the main result set.\n */\n const childResults = buildSearchableFieldList({\n fields: childFields,\n parents: [...parents, field.fieldId],\n plugins,\n input\n });\n\n result.push(...childResults);\n return result;\n }\n /**\n * If not searchable, continue further.\n */\n if (!plugin.fullTextSearch || field.settings?.disableFullTextSearch === true) {\n return result;\n }\n\n /**\n * Combine all parent paths with the current one and push it.\n */\n const path = [...parents, field.fieldId].join(\".\");\n result.push(path);\n\n return result;\n },\n /**\n * We always add id and entry id\n */\n [\"id\", \"entryId\"]\n );\n};\n\ninterface Params {\n input: string[];\n fields: CmsModelField[];\n plugins: PluginsContainer;\n}\nexport const getSearchableFields = (params: Params): string[] => {\n const { plugins, input, fields } = params;\n const fieldPluginMap = plugins\n .byType<CmsModelFieldToGraphQLPlugin>(\"cms-model-field-to-graphql\")\n .reduce<Record<string, CmsModelFieldToGraphQLPlugin>>((collection, field) => {\n collection[field.fieldType] = field;\n return collection;\n }, {});\n\n return buildSearchableFieldList({\n fields,\n input,\n plugins: fieldPluginMap,\n parents: [\"values\"]\n });\n};\n"],"mappings":"AASA,MAAMA,wBAAwB,GAAIC,MAAmB,IAAe;EAChE,MAAM;IAAEC,KAAK;IAAEC,OAAO;IAAEC,MAAM;IAAEC;EAAQ,CAAC,GAAGJ,MAAM;EAClD,OAAOG,MAAM,CAACE,MAAM,CAChB,CAACC,MAAM,EAAEC,KAAK,KAAK;IACf;AACZ;AACA;IACY,MAAMC,MAAM,GAAGN,OAAO,CAACK,KAAK,CAACE,IAAI,CAAC;IAClC,IAAI,CAACD,MAAM,EAAE;MACT,OAAOF,MAAM;IACjB;IACA;AACZ;AACA;I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cAAc;IACvBjB,OAAO,EAAE,CAAC,QAAQ;EACtB,CAAC,CAAC;AACN,CAAC","ignoreList":[]}
@@ -1,7 +1,7 @@
1
1
  import { Result } from "@webiny/feature/api";
2
- import { GetUniqueFieldValuesUseCase as UseCaseAbstraction, GetUniqueFieldValuesRepository, GetUniqueFieldValuesParams } from "./abstractions.js";
2
+ import { GetUniqueFieldValuesParams, GetUniqueFieldValuesRepository, GetUniqueFieldValuesUseCase as UseCaseAbstraction } from "./abstractions.js";
3
3
  import { AccessControl, CmsContext } from "../../../features/shared/abstractions.js";
4
- import type { CmsModel, CmsEntryUniqueValue } from "../../../types/index.js";
4
+ import type { CmsEntryUniqueValue, CmsModel } from "../../../types/index.js";
5
5
  declare class GetUniqueFieldValuesUseCaseImpl implements UseCaseAbstraction.Interface {
6
6
  private repository;
7
7
  private accessControl;
@@ -1,6 +1,5 @@
1
- import { Result } from "@webiny/feature/api";
2
- import { createImplementation } from "@webiny/feature/api";
3
- import { GetUniqueFieldValuesUseCase as UseCaseAbstraction, GetUniqueFieldValuesRepository } from "./abstractions.js";
1
+ import { createImplementation, Result } from "@webiny/feature/api";
2
+ import { GetUniqueFieldValuesRepository, GetUniqueFieldValuesUseCase as UseCaseAbstraction } from "./abstractions.js";
4
3
  import { AccessControl, CmsContext } from "../../shared/abstractions.js";
5
4
  import { EntryNotAuthorizedError } from "../../../domain/contentEntry/errors.js";
6
5
  import { FieldNotSearchableError, InvalidWhereConditionError } from "./errors.js";
@@ -54,7 +53,7 @@ class GetUniqueFieldValuesUseCaseImpl {
54
53
  plugins: this.cmsContext.plugins,
55
54
  input: []
56
55
  });
57
- if (!searchableFields.includes(fieldId)) {
56
+ if (!searchableFields.includes(`values.${fieldId}`)) {
58
57
  return Result.fail(new FieldNotSearchableError(fieldId));
59
58
  }
60
59
 
@@ -1 +1 @@
1
- {"version":3,"names":["Result","createImplementation","GetUniqueFieldValuesUseCase","UseCaseAbstraction","GetUniqueFieldValuesRepository","AccessControl","CmsContext","EntryNotAuthorizedError","FieldNotSearchableError","InvalidWhereConditionError","getSearchableFields","GetUniqueFieldValuesUseCaseImpl","constructor","repository","accessControl","cmsContext","execute","model","params","ensureCanAccessEntry","error","fail","where","initialWhere","fieldId","canAccessOnlyOwned","canAccessOnlyOwnedEntries","identity","security","getIdentity","createdBy","id","latest","published","searchableFields","fields","plugins","input","includes","result","isFail","ok","value","abstraction","implementation","dependencies"],"sources":["GetUniqueFieldValuesUseCase.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { createImplementation } from \"@webiny/feature/api\";\nimport {\n GetUniqueFieldValuesUseCase as UseCaseAbstraction,\n GetUniqueFieldValuesRepository,\n GetUniqueFieldValuesParams\n} from \"./abstractions.js\";\nimport { AccessControl, CmsContext } from \"~/features/shared/abstractions.js\";\nimport { EntryNotAuthorizedError } from \"~/domain/contentEntry/errors.js\";\nimport { FieldNotSearchableError, InvalidWhereConditionError } from \"./errors.js\";\nimport { getSearchableFields } from \"~/crud/contentEntry/searchableFields.js\";\nimport type { CmsModel, CmsEntryUniqueValue } from \"~/types/index.js\";\n\nclass GetUniqueFieldValuesUseCaseImpl implements UseCaseAbstraction.Interface {\n public constructor(\n private repository: GetUniqueFieldValuesRepository.Interface,\n private accessControl: AccessControl.Interface,\n private cmsContext: CmsContext.Interface\n ) {}\n\n async execute(\n model: CmsModel,\n params: GetUniqueFieldValuesParams\n ): Promise<Result<CmsEntryUniqueValue[], UseCaseAbstraction.Error>> {\n // Check access control - throws if not authorized\n try {\n await this.accessControl.ensureCanAccessEntry({ model });\n } catch (error) {\n if (error instanceof EntryNotAuthorizedError) {\n return Result.fail(error);\n }\n throw error;\n }\n\n const { where: initialWhere, fieldId } = params;\n\n const where = {\n ...initialWhere\n };\n\n // Apply ownership filter if needed\n const canAccessOnlyOwned = await this.accessControl.canAccessOnlyOwnedEntries({ model });\n if (canAccessOnlyOwned) {\n const identity = this.cmsContext.security.getIdentity();\n where.createdBy = identity.id;\n }\n\n // Validate where conditions\n if (where.latest && where.published) {\n return Result.fail(\n new InvalidWhereConditionError(\n \"Cannot list entries that are both published and latest.\",\n where\n )\n );\n }\n\n if (!where.latest && !where.published) {\n return Result.fail(\n new InvalidWhereConditionError(\n \"Cannot list entries if we do not have latest or published defined.\",\n where\n )\n );\n }\n\n // Verify the field is searchable\n const searchableFields = getSearchableFields({\n fields: model.fields,\n plugins: this.cmsContext.plugins,\n input: []\n });\n\n if (!searchableFields.includes(fieldId)) {\n return Result.fail(new FieldNotSearchableError(fieldId));\n }\n\n // Execute repository call\n const result = await this.repository.execute(model, { where, fieldId });\n if (result.isFail()) {\n return Result.fail(result.error);\n }\n\n return Result.ok(result.value);\n }\n}\n\nexport const GetUniqueFieldValuesUseCase = createImplementation({\n abstraction: UseCaseAbstraction,\n implementation: GetUniqueFieldValuesUseCaseImpl,\n dependencies: [GetUniqueFieldValuesRepository, AccessControl, CmsContext]\n});\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,qBAAqB;AAC5C,SAASC,oBAAoB,QAAQ,qBAAqB;AAC1D,SACIC,2BAA2B,IAAIC,kBAAkB,EACjDC,8BAA8B;AAGlC,SAASC,aAAa,EAAEC,UAAU;AAClC,SAASC,uBAAuB;AAChC,SAASC,uBAAuB,EAAEC,0BAA0B;AAC5D,SAASC,mBAAmB;AAG5B,MAAMC,+BAA+B,CAAyC;EACnEC,WAAWA,CACNC,UAAoD,EACpDC,aAAsC,EACtCC,UAAgC,EAC1C;IAAA,KAHUF,UAAoD,GAApDA,UAAoD;IAAA,KACpDC,aAAsC,GAAtCA,aAAsC;IAAA,KACtCC,UAAgC,GAAhCA,UAAgC;EACzC;EAEH,MAAMC,OAAOA,CACTC,KAAe,EACfC,MAAkC,EAC8B;IAChE;IACA,IAAI;MACA,MAAM,IAAI,CAACJ,aAAa,CAACK,oBAAoB,CAAC;QAAEF;MAAM,CAAC,CAAC;IAC5D,CAAC,CAAC,OAAOG,KAAK,EAAE;MACZ,IAAIA,KAAK,YAAYb,uBAAuB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AK,EAAE;MAAEK,KAAK;MAAEE;IAAQ,CAAC,CAAC;IACvE,IAAIe,MAAM,CAACC,MAAM,CAAC,CAAC,EAAE;MACjB,OAAOxC,MAAM,CAACqB,IAAI,CAACkB,MAAM,CAACnB,KAAK,CAAC;IACpC;IAEA,OAAOpB,MAAM,CAACyC,EAAE,CAACF,MAAM,CAACG,KAAK,CAAC;EAClC;AACJ;AAEA,OAAO,MAAMxC,2BAA2B,GAAGD,oBAAoB,CAAC;EAC5D0C,WAAW,EAAExC,kBAAkB;EAC/ByC,cAAc,EAAEjC,+BAA+B;EAC/CkC,YAAY,EAAE,CAACzC,8BAA8B,EAAEC,aAAa,EAAEC,UAAU;AAC5E,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["createImplementation","Result","GetUniqueFieldValuesRepository","GetUniqueFieldValuesUseCase","UseCaseAbstraction","AccessControl","CmsContext","EntryNotAuthorizedError","FieldNotSearchableError","InvalidWhereConditionError","getSearchableFields","GetUniqueFieldValuesUseCaseImpl","constructor","repository","accessControl","cmsContext","execute","model","params","ensureCanAccessEntry","error","fail","where","initialWhere","fieldId","canAccessOnlyOwned","canAccessOnlyOwnedEntries","identity","security","getIdentity","createdBy","id","latest","published","searchableFields","fields","plugins","input","includes","result","isFail","ok","value","abstraction","implementation","dependencies"],"sources":["GetUniqueFieldValuesUseCase.ts"],"sourcesContent":["import { createImplementation, Result } from \"@webiny/feature/api\";\nimport {\n GetUniqueFieldValuesParams,\n GetUniqueFieldValuesRepository,\n GetUniqueFieldValuesUseCase as UseCaseAbstraction\n} from \"./abstractions.js\";\nimport { AccessControl, CmsContext } from \"~/features/shared/abstractions.js\";\nimport { EntryNotAuthorizedError } from \"~/domain/contentEntry/errors.js\";\nimport { FieldNotSearchableError, InvalidWhereConditionError } from \"./errors.js\";\nimport { getSearchableFields } from \"~/crud/contentEntry/searchableFields.js\";\nimport type { CmsEntryUniqueValue, CmsModel } from \"~/types/index.js\";\n\nclass GetUniqueFieldValuesUseCaseImpl implements UseCaseAbstraction.Interface {\n public constructor(\n private repository: GetUniqueFieldValuesRepository.Interface,\n private accessControl: AccessControl.Interface,\n private cmsContext: CmsContext.Interface\n ) {}\n\n async execute(\n model: CmsModel,\n params: GetUniqueFieldValuesParams\n ): Promise<Result<CmsEntryUniqueValue[], UseCaseAbstraction.Error>> {\n // Check access control - throws if not authorized\n try {\n await this.accessControl.ensureCanAccessEntry({ model });\n } catch (error) {\n if (error instanceof EntryNotAuthorizedError) {\n return Result.fail(error);\n }\n throw error;\n }\n\n const { where: initialWhere, fieldId } = params;\n\n const where = {\n ...initialWhere\n };\n\n // Apply ownership filter if needed\n const canAccessOnlyOwned = await this.accessControl.canAccessOnlyOwnedEntries({ model });\n if (canAccessOnlyOwned) {\n const identity = this.cmsContext.security.getIdentity();\n where.createdBy = identity.id;\n }\n\n // Validate where conditions\n if (where.latest && where.published) {\n return Result.fail(\n new InvalidWhereConditionError(\n \"Cannot list entries that are both published and latest.\",\n where\n )\n );\n }\n\n if (!where.latest && !where.published) {\n return Result.fail(\n new InvalidWhereConditionError(\n \"Cannot list entries if we do not have latest or published defined.\",\n where\n )\n );\n }\n\n // Verify the field is searchable\n const searchableFields = getSearchableFields({\n fields: model.fields,\n plugins: this.cmsContext.plugins,\n input: []\n });\n\n if (!searchableFields.includes(`values.${fieldId}`)) {\n return Result.fail(new FieldNotSearchableError(fieldId));\n }\n\n // Execute repository call\n const result = await this.repository.execute(model, {\n where,\n fieldId\n });\n if (result.isFail()) {\n return Result.fail(result.error);\n }\n\n return Result.ok(result.value);\n }\n}\n\nexport const GetUniqueFieldValuesUseCase = createImplementation({\n abstraction: UseCaseAbstraction,\n implementation: GetUniqueFieldValuesUseCaseImpl,\n dependencies: [GetUniqueFieldValuesRepository, AccessControl, CmsContext]\n});\n"],"mappings":"AAAA,SAASA,oBAAoB,EAAEC,MAAM,QAAQ,qBAAqB;AAClE,SAEIC,8BAA8B,EAC9BC,2BAA2B,IAAIC,kBAAkB;AAErD,SAASC,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AAS,EAAE;MACnC,OAAOhC,MAAM,CAACoB,IAAI,CACd,IAAIZ,0BAA0B,CAC1B,oEAAoE,EACpEa,KACJ,CACJ,CAAC;IACL;;IAEA;IACA,MAAMY,gBAAgB,GAAGxB,mBAAmB,CAAC;MACzCyB,MAAM,EAAElB,KAAK,CAACkB,MAAM;MACpBC,OAAO,EAAE,IAAI,CAACrB,UAAU,CAACqB,OAAO;MAChCC,KAAK,EAAE;IACX,CAAC,CAAC;IAEF,IAAI,CAACH,gBAAgB,CAACI,QAAQ,CAAC,UAAUd,OAAO,EAAE,CAAC,EAAE;MACjD,OAAOvB,MAAM,CAACoB,IAAI,CAAC,IAAIb,uBAAuB,CAACgB,OAAO,CAAC,CAAC;IAC5D;;IAEA;IACA,MAAMe,MAAM,GAAG,MAAM,IAAI,CAAC1B,UAAU,CAACG,OAAO,CAACC,KAAK,EAAE;MAChDK,KAAK;MACLE;IACJ,CAAC,CAAC;IACF,IAAIe,MAAM,CAACC,MAAM,CAAC,CAAC,EAAE;MACjB,OAAOvC,MAAM,CAACoB,IAAI,CAACkB,MAAM,CAACnB,KAAK,CAAC;IACpC;IAEA,OAAOnB,MAAM,CAACwC,EAAE,CAACF,MAAM,CAACG,KAAK,CAAC;EAClC;AACJ;AAEA,OAAO,MAAMvC,2BAA2B,GAAGH,oBAAoB,CAAC;EAC5D2C,WAAW,EAAEvC,kBAAkB;EAC/BwC,cAAc,EAAEjC,+BAA+B;EAC/CkC,YAAY,EAAE,CAAC3C,8BAA8B,EAAEG,aAAa,EAAEC,UAAU;AAC5E,CAAC,CAAC","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/api-headless-cms",
3
- "version": "6.0.0-rc.3",
3
+ "version": "6.0.0-rc.5",
4
4
  "type": "module",
5
5
  "main": "index.js",
6
6
  "keywords": [
@@ -22,19 +22,19 @@
22
22
  "@babel/code-frame": "7.29.0",
23
23
  "@graphql-tools/merge": "9.1.7",
24
24
  "@graphql-tools/schema": "10.0.31",
25
- "@webiny/api": "6.0.0-rc.3",
26
- "@webiny/api-core": "6.0.0-rc.3",
25
+ "@webiny/api": "6.0.0-rc.5",
26
+ "@webiny/api-core": "6.0.0-rc.5",
27
27
  "@webiny/di": "0.2.3",
28
- "@webiny/error": "6.0.0-rc.3",
29
- "@webiny/feature": "6.0.0-rc.3",
30
- "@webiny/handler": "6.0.0-rc.3",
31
- "@webiny/handler-aws": "6.0.0-rc.3",
32
- "@webiny/handler-db": "6.0.0-rc.3",
33
- "@webiny/handler-graphql": "6.0.0-rc.3",
34
- "@webiny/plugins": "6.0.0-rc.3",
35
- "@webiny/project": "6.0.0-rc.3",
36
- "@webiny/utils": "6.0.0-rc.3",
37
- "@webiny/validation": "6.0.0-rc.3",
28
+ "@webiny/error": "6.0.0-rc.5",
29
+ "@webiny/feature": "6.0.0-rc.5",
30
+ "@webiny/handler": "6.0.0-rc.5",
31
+ "@webiny/handler-aws": "6.0.0-rc.5",
32
+ "@webiny/handler-db": "6.0.0-rc.5",
33
+ "@webiny/handler-graphql": "6.0.0-rc.5",
34
+ "@webiny/plugins": "6.0.0-rc.5",
35
+ "@webiny/project": "6.0.0-rc.5",
36
+ "@webiny/utils": "6.0.0-rc.5",
37
+ "@webiny/validation": "6.0.0-rc.5",
38
38
  "dot-prop-immutable": "2.1.1",
39
39
  "graphql": "16.13.0",
40
40
  "graphql-tag": "2.12.6",
@@ -48,13 +48,13 @@
48
48
  "devDependencies": {
49
49
  "@types/babel__code-frame": "7.27.0",
50
50
  "@types/pluralize": "0.0.33",
51
- "@webiny/aws-sdk": "6.0.0-rc.3",
52
- "@webiny/build-tools": "6.0.0-rc.3",
53
- "@webiny/db-dynamodb": "6.0.0-rc.3",
51
+ "@webiny/aws-sdk": "6.0.0-rc.5",
52
+ "@webiny/build-tools": "6.0.0-rc.5",
53
+ "@webiny/db-dynamodb": "6.0.0-rc.5",
54
54
  "@webiny/handler-db": "0.0.0",
55
- "@webiny/project-utils": "6.0.0-rc.3",
56
- "@webiny/sdk": "6.0.0-rc.3",
57
- "@webiny/wcp": "6.0.0-rc.3",
55
+ "@webiny/project-utils": "6.0.0-rc.5",
56
+ "@webiny/sdk": "6.0.0-rc.5",
57
+ "@webiny/wcp": "6.0.0-rc.5",
58
58
  "apollo-graphql": "0.9.7",
59
59
  "graphql": "16.13.0",
60
60
  "prettier": "3.6.2",
@@ -67,5 +67,5 @@
67
67
  "access": "public",
68
68
  "directory": "dist"
69
69
  },
70
- "gitHead": "228fe25e1a17f248d566bce1c33d11c291955513"
70
+ "gitHead": "8f9b60f1193682a21e037e6f771b19f1dfd65045"
71
71
  }