@webiny/api-headless-cms 6.3.0-beta.2 → 6.3.0-beta.4

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.
Files changed (51) hide show
  1. package/crud/contentEntry/entryDataFactories/createEntryData.js +1 -1
  2. package/crud/contentEntry/entryDataFactories/createEntryData.js.map +1 -1
  3. package/features/contentModel/ContentModelFeature.js +2 -0
  4. package/features/contentModel/ContentModelFeature.js.map +1 -1
  5. package/features/contentModel/CreateModel/CreateModelRepository.d.ts +11 -11
  6. package/features/contentModel/CreateModel/CreateModelRepository.js +12 -10
  7. package/features/contentModel/CreateModel/CreateModelRepository.js.map +1 -1
  8. package/features/contentModel/CreateModelFrom/CreateModelFromRepository.d.ts +11 -12
  9. package/features/contentModel/CreateModelFrom/CreateModelFromRepository.js +12 -11
  10. package/features/contentModel/CreateModelFrom/CreateModelFromRepository.js.map +1 -1
  11. package/features/contentModel/ModelFieldCompression/ModelFieldCompression.d.ts +15 -0
  12. package/features/contentModel/ModelFieldCompression/ModelFieldCompression.js +27 -0
  13. package/features/contentModel/ModelFieldCompression/ModelFieldCompression.js.map +1 -0
  14. package/features/contentModel/ModelFieldCompression/abstractions.d.ts +17 -0
  15. package/features/contentModel/ModelFieldCompression/abstractions.js +4 -0
  16. package/features/contentModel/ModelFieldCompression/abstractions.js.map +1 -0
  17. package/features/contentModel/ModelFieldCompression/feature.d.ts +4 -0
  18. package/features/contentModel/ModelFieldCompression/feature.js +10 -0
  19. package/features/contentModel/ModelFieldCompression/feature.js.map +1 -0
  20. package/features/contentModel/ModelFieldCompression/index.d.ts +1 -0
  21. package/features/contentModel/ModelFieldCompression/index.js +3 -0
  22. package/features/contentModel/ModelFieldCompression/index.js.map +1 -0
  23. package/features/contentModel/UpdateModel/UpdateModelRepository.d.ts +9 -9
  24. package/features/contentModel/UpdateModel/UpdateModelRepository.js +13 -10
  25. package/features/contentModel/UpdateModel/UpdateModelRepository.js.map +1 -1
  26. package/features/contentModel/shared/ModelsFetcher.d.ts +7 -5
  27. package/features/contentModel/shared/ModelsFetcher.js +13 -3
  28. package/features/contentModel/shared/ModelsFetcher.js.map +1 -1
  29. package/features/modelBuilder/fields/DateTimeFieldType.js +20 -0
  30. package/features/modelBuilder/fields/DateTimeFieldType.js.map +1 -1
  31. package/graphql/schema/cms/createEntryResolver.js +9 -0
  32. package/graphql/schema/cms/createEntryResolver.js.map +1 -1
  33. package/graphql/schema/cms/deleteEntryResolver.js +9 -0
  34. package/graphql/schema/cms/deleteEntryResolver.js.map +1 -1
  35. package/graphql/schema/cms/getEntryResolver.js +9 -0
  36. package/graphql/schema/cms/getEntryResolver.js.map +1 -1
  37. package/graphql/schema/cms/listEntriesResolver.js +14 -0
  38. package/graphql/schema/cms/listEntriesResolver.js.map +1 -1
  39. package/graphql/schema/cms/publishEntryResolver.js +9 -0
  40. package/graphql/schema/cms/publishEntryResolver.js.map +1 -1
  41. package/graphql/schema/cms/unpublishEntryResolver.js +9 -0
  42. package/graphql/schema/cms/unpublishEntryResolver.js.map +1 -1
  43. package/graphql/schema/cms/updateEntryResolver.js +9 -0
  44. package/graphql/schema/cms/updateEntryResolver.js.map +1 -1
  45. package/package.json +27 -24
  46. package/types/model.d.ts +7 -0
  47. package/types/model.js.map +1 -1
  48. package/types/types.d.ts +8 -8
  49. package/types/types.js.map +1 -1
  50. package/utils/toSlug.js +1 -1
  51. package/utils/toSlug.js.map +1 -1
@@ -0,0 +1,3 @@
1
+ export { ModelFieldCompression } from "./abstractions.js";
2
+
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["ModelFieldCompression"],"sources":["index.ts"],"sourcesContent":["export { ModelFieldCompression } from \"./abstractions.js\";\n"],"mappings":"AAAA,SAASA,qBAAqB","ignoreList":[]}
@@ -1,10 +1,9 @@
1
1
  import { Result } from "@webiny/feature/api";
2
2
  import { UpdateModelRepository as RepositoryAbstraction } from "./abstractions.js";
3
- import { ModelCache } from "../../../features/contentModel/shared/abstractions.js";
4
- import { ModelsFetcher } from "../../../features/contentModel/shared/abstractions.js";
5
- import { StorageOperations } from "../../../features/shared/abstractions.js";
6
- import { CmsContext } from "../../../features/shared/abstractions.js";
3
+ import { ModelCache, ModelsFetcher } from "../../../features/contentModel/shared/abstractions.js";
4
+ import { CmsContext, StorageOperations } from "../../../features/shared/abstractions.js";
7
5
  import type { CmsModel } from "../../../types/index.js";
6
+ import { ModelFieldCompression } from "../../../features/contentModel/ModelFieldCompression/index.js";
8
7
  /**
9
8
  * UpdateModelRepository - Validates domain rules and persists model updates.
10
9
  *
@@ -17,11 +16,12 @@ import type { CmsModel } from "../../../types/index.js";
17
16
  * - Clear ModelCache after successful update
18
17
  */
19
18
  declare class UpdateModelRepositoryImpl implements RepositoryAbstraction.Interface {
20
- private modelCache;
21
- private modelsFetcher;
22
- private storageOperations;
23
- private cmsContext;
24
- constructor(modelCache: ModelCache.Interface, modelsFetcher: ModelsFetcher.Interface, storageOperations: StorageOperations.Interface, cmsContext: CmsContext.Interface);
19
+ private readonly modelCache;
20
+ private readonly modelsFetcher;
21
+ private readonly storageOperations;
22
+ private readonly cmsContext;
23
+ private readonly modelFieldCompression;
24
+ constructor(modelCache: ModelCache.Interface, modelsFetcher: ModelsFetcher.Interface, storageOperations: StorageOperations.Interface, cmsContext: CmsContext.Interface, modelFieldCompression: ModelFieldCompression.Interface);
25
25
  execute(model: CmsModel, original: CmsModel): Promise<Result<void, RepositoryAbstraction.Error>>;
26
26
  }
27
27
  export declare const UpdateModelRepository: typeof UpdateModelRepositoryImpl & {
@@ -1,16 +1,14 @@
1
1
  import { Result } from "@webiny/feature/api";
2
2
  import { UpdateModelRepository as RepositoryAbstraction } from "./abstractions.js";
3
- import { ModelCache } from "../shared/abstractions.js";
4
- import { ModelsFetcher } from "../shared/abstractions.js";
5
- import { ModelCannotUpdateCodeModelError } from "../../../domain/contentModel/errors.js";
6
- import { ModelPersistenceError } from "../../../domain/contentModel/errors.js";
7
- import { ModelValidationError } from "../../../domain/contentModel/errors.js";
8
- import { StorageOperations } from "../../shared/abstractions.js";
9
- import { CmsContext } from "../../shared/abstractions.js";
3
+ import { ModelCache, ModelsFetcher } from "../shared/abstractions.js";
4
+ import { ModelCannotUpdateCodeModelError, ModelPersistenceError, ModelValidationError } from "../../../domain/contentModel/errors.js";
5
+ import { CmsContext, StorageOperations } from "../../shared/abstractions.js";
10
6
  import { validateEndingAllowed } from "../../../crud/contentModel/validate/endingAllowed.js";
11
7
  import { validateSingularApiName } from "../../../domain/contentModel/validation/singularApiName.js";
12
8
  import { validatePluralApiName } from "../../../domain/contentModel/validation/pluralApiName.js";
13
9
  import { validateModelFields } from "../../../domain/contentModel/validation/modelFields.js";
10
+ import { ModelFieldCompression } from "../ModelFieldCompression/index.js";
11
+
14
12
  /**
15
13
  * UpdateModelRepository - Validates domain rules and persists model updates.
16
14
  *
@@ -23,11 +21,12 @@ import { validateModelFields } from "../../../domain/contentModel/validation/mod
23
21
  * - Clear ModelCache after successful update
24
22
  */
25
23
  class UpdateModelRepositoryImpl {
26
- constructor(modelCache, modelsFetcher, storageOperations, cmsContext) {
24
+ constructor(modelCache, modelsFetcher, storageOperations, cmsContext, modelFieldCompression) {
27
25
  this.modelCache = modelCache;
28
26
  this.modelsFetcher = modelsFetcher;
29
27
  this.storageOperations = storageOperations;
30
28
  this.cmsContext = cmsContext;
29
+ this.modelFieldCompression = modelFieldCompression;
31
30
  }
32
31
  async execute(model, original) {
33
32
  try {
@@ -88,10 +87,14 @@ class UpdateModelRepositoryImpl {
88
87
  data: error.data
89
88
  }));
90
89
  }
90
+ const fields = await this.modelFieldCompression.compress(model.fields);
91
91
 
92
92
  // Persist to storage
93
93
  await this.storageOperations.models.update({
94
- model
94
+ model: {
95
+ ...model,
96
+ fields
97
+ }
95
98
  });
96
99
 
97
100
  // Clear cache
@@ -104,7 +107,7 @@ class UpdateModelRepositoryImpl {
104
107
  }
105
108
  export const UpdateModelRepository = RepositoryAbstraction.createImplementation({
106
109
  implementation: UpdateModelRepositoryImpl,
107
- dependencies: [ModelCache, ModelsFetcher, StorageOperations, CmsContext]
110
+ dependencies: [ModelCache, ModelsFetcher, StorageOperations, CmsContext, ModelFieldCompression]
108
111
  });
109
112
 
110
113
  //# sourceMappingURL=UpdateModelRepository.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["Result","UpdateModelRepository","RepositoryAbstraction","ModelCache","ModelsFetcher","ModelCannotUpdateCodeModelError","ModelPersistenceError","ModelValidationError","StorageOperations","CmsContext","validateEndingAllowed","validateSingularApiName","validatePluralApiName","validateModelFields","UpdateModelRepositoryImpl","constructor","modelCache","modelsFetcher","storageOperations","cmsContext","execute","model","original","error","fail","message","data","modelsResult","security","withoutAuthorization","fetchAll","isFail","allModels","value","models","filter","m","modelId","existingModelResult","fetchById","isPlugin","existingModel","context","update","clear","ok","createImplementation","implementation","dependencies"],"sources":["UpdateModelRepository.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { UpdateModelRepository as RepositoryAbstraction } from \"./abstractions.js\";\nimport { ModelCache } from \"~/features/contentModel/shared/abstractions.js\";\nimport { ModelsFetcher } from \"~/features/contentModel/shared/abstractions.js\";\nimport { ModelCannotUpdateCodeModelError } from \"~/domain/contentModel/errors.js\";\nimport { ModelPersistenceError } from \"~/domain/contentModel/errors.js\";\nimport { ModelValidationError } from \"~/domain/contentModel/errors.js\";\nimport { StorageOperations } from \"~/features/shared/abstractions.js\";\nimport { CmsContext } from \"~/features/shared/abstractions.js\";\nimport { validateEndingAllowed } from \"~/crud/contentModel/validate/endingAllowed.js\";\nimport { validateSingularApiName } from \"~/domain/contentModel/validation/singularApiName.js\";\nimport { validatePluralApiName } from \"~/domain/contentModel/validation/pluralApiName.js\";\nimport { validateModelFields } from \"~/domain/contentModel/validation/modelFields.js\";\nimport type { CmsModel } from \"~/types/index.js\";\n\n/**\n * UpdateModelRepository - Validates domain rules and persists model updates.\n *\n * Responsibilities:\n * - Validate API name endings\n * - Validate singularApiName uniqueness (excluding current model)\n * - Validate pluralApiName uniqueness (excluding current model)\n * - Validate model fields\n * - Persist to storage\n * - Clear ModelCache after successful update\n */\nclass UpdateModelRepositoryImpl implements RepositoryAbstraction.Interface {\n public constructor(\n private modelCache: ModelCache.Interface,\n private modelsFetcher: ModelsFetcher.Interface,\n private storageOperations: StorageOperations.Interface,\n private cmsContext: CmsContext.Interface\n ) {}\n\n async execute(\n model: CmsModel,\n original: CmsModel\n ): Promise<Result<void, RepositoryAbstraction.Error>> {\n try {\n // Validate API name endings\n try {\n validateEndingAllowed({ model });\n } catch (error) {\n return Result.fail(\n new ModelValidationError({ message: error.message, data: error.data })\n );\n }\n\n // Get all models for validation (excluding the current model)\n const modelsResult = await this.cmsContext.security.withoutAuthorization(async () => {\n return await this.modelsFetcher.fetchAll();\n });\n\n if (modelsResult.isFail()) {\n return Result.fail(new ModelPersistenceError(modelsResult.error));\n }\n\n const allModels = modelsResult.value;\n const models = allModels.filter(m => m.modelId !== model.modelId);\n\n // Check if this is a plugin model\n const existingModelResult = await this.modelsFetcher.fetchById(model.modelId);\n if (existingModelResult.isFail()) {\n return Result.fail(new ModelPersistenceError(existingModelResult.error));\n }\n\n if (existingModelResult.value.isPlugin) {\n return Result.fail(new ModelCannotUpdateCodeModelError(model.modelId));\n }\n\n // Validate uniqueness\n try {\n for (const existingModel of models) {\n validateSingularApiName({\n existingModel,\n model\n });\n validatePluralApiName({\n existingModel,\n model\n });\n }\n\n // Validate model fields\n await validateModelFields({\n models,\n model,\n original,\n context: this.cmsContext\n });\n } catch (error) {\n return Result.fail(\n new ModelValidationError({ message: error.message, data: error.data })\n );\n }\n\n // Persist to storage\n await this.storageOperations.models.update({ model });\n\n // Clear cache\n this.modelCache.clear();\n\n return Result.ok();\n } catch (error) {\n return Result.fail(new ModelPersistenceError(error as Error));\n }\n }\n}\n\nexport const UpdateModelRepository = RepositoryAbstraction.createImplementation({\n implementation: UpdateModelRepositoryImpl,\n dependencies: [ModelCache, ModelsFetcher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;MAAM,CAAC,CAAC;;MAErD;MACA,IAAI,CAACL,UAAU,CAAC4B,KAAK,CAAC,CAAC;MAEvB,OAAO5C,MAAM,CAAC6C,EAAE,CAAC,CAAC;IACtB,CAAC,CAAC,OAAOtB,KAAK,EAAE;MACZ,OAAOvB,MAAM,CAACwB,IAAI,CAAC,IAAIlB,qBAAqB,CAACiB,KAAc,CAAC,CAAC;IACjE;EACJ;AACJ;AAEA,OAAO,MAAMtB,qBAAqB,GAAGC,qBAAqB,CAAC4C,oBAAoB,CAAC;EAC5EC,cAAc,EAAEjC,yBAAyB;EACzCkC,YAAY,EAAE,CAAC7C,UAAU,EAAEC,aAAa,EAAEI,iBAAiB,EAAEC,UAAU;AAC3E,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["Result","UpdateModelRepository","RepositoryAbstraction","ModelCache","ModelsFetcher","ModelCannotUpdateCodeModelError","ModelPersistenceError","ModelValidationError","CmsContext","StorageOperations","validateEndingAllowed","validateSingularApiName","validatePluralApiName","validateModelFields","ModelFieldCompression","UpdateModelRepositoryImpl","constructor","modelCache","modelsFetcher","storageOperations","cmsContext","modelFieldCompression","execute","model","original","error","fail","message","data","modelsResult","security","withoutAuthorization","fetchAll","isFail","allModels","value","models","filter","m","modelId","existingModelResult","fetchById","isPlugin","existingModel","context","fields","compress","update","clear","ok","createImplementation","implementation","dependencies"],"sources":["UpdateModelRepository.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { UpdateModelRepository as RepositoryAbstraction } from \"./abstractions.js\";\nimport { ModelCache, ModelsFetcher } from \"~/features/contentModel/shared/abstractions.js\";\nimport {\n ModelCannotUpdateCodeModelError,\n ModelPersistenceError,\n ModelValidationError\n} from \"~/domain/contentModel/errors.js\";\nimport { CmsContext, StorageOperations } from \"~/features/shared/abstractions.js\";\nimport { validateEndingAllowed } from \"~/crud/contentModel/validate/endingAllowed.js\";\nimport { validateSingularApiName } from \"~/domain/contentModel/validation/singularApiName.js\";\nimport { validatePluralApiName } from \"~/domain/contentModel/validation/pluralApiName.js\";\nimport { validateModelFields } from \"~/domain/contentModel/validation/modelFields.js\";\nimport type { CmsModel } from \"~/types/index.js\";\nimport { ModelFieldCompression } from \"~/features/contentModel/ModelFieldCompression/index.js\";\n\n/**\n * UpdateModelRepository - Validates domain rules and persists model updates.\n *\n * Responsibilities:\n * - Validate API name endings\n * - Validate singularApiName uniqueness (excluding current model)\n * - Validate pluralApiName uniqueness (excluding current model)\n * - Validate model fields\n * - Persist to storage\n * - Clear ModelCache after successful update\n */\nclass UpdateModelRepositoryImpl implements RepositoryAbstraction.Interface {\n public constructor(\n private readonly modelCache: ModelCache.Interface,\n private readonly modelsFetcher: ModelsFetcher.Interface,\n private readonly storageOperations: StorageOperations.Interface,\n private readonly cmsContext: CmsContext.Interface,\n private readonly modelFieldCompression: ModelFieldCompression.Interface\n ) {}\n\n async execute(\n model: CmsModel,\n original: CmsModel\n ): Promise<Result<void, RepositoryAbstraction.Error>> {\n try {\n // Validate API name endings\n try {\n validateEndingAllowed({ model });\n } catch (error) {\n return Result.fail(\n new ModelValidationError({ message: error.message, data: error.data })\n );\n }\n\n // Get all models for validation (excluding the current model)\n const modelsResult = await this.cmsContext.security.withoutAuthorization(async () => {\n return await this.modelsFetcher.fetchAll();\n });\n\n if (modelsResult.isFail()) {\n return Result.fail(new ModelPersistenceError(modelsResult.error));\n }\n\n const allModels = modelsResult.value;\n const models = allModels.filter(m => m.modelId !== model.modelId);\n\n // Check if this is a plugin model\n const existingModelResult = await this.modelsFetcher.fetchById(model.modelId);\n if (existingModelResult.isFail()) {\n return Result.fail(new ModelPersistenceError(existingModelResult.error));\n }\n\n if (existingModelResult.value.isPlugin) {\n return Result.fail(new ModelCannotUpdateCodeModelError(model.modelId));\n }\n\n // Validate uniqueness\n try {\n for (const existingModel of models) {\n validateSingularApiName({\n existingModel,\n model\n });\n validatePluralApiName({\n existingModel,\n model\n });\n }\n\n // Validate model fields\n await validateModelFields({\n models,\n model,\n original,\n context: this.cmsContext\n });\n } catch (error) {\n return Result.fail(\n new ModelValidationError({ message: error.message, data: error.data })\n );\n }\n\n const fields = await this.modelFieldCompression.compress(model.fields);\n\n // Persist to storage\n await this.storageOperations.models.update({\n model: {\n ...model,\n fields\n }\n });\n\n // Clear cache\n this.modelCache.clear();\n\n return Result.ok();\n } catch (error) {\n return Result.fail(new ModelPersistenceError(error as Error));\n }\n }\n}\n\nexport const UpdateModelRepository = RepositoryAbstraction.createImplementation({\n implementation: UpdateModelRepositoryImpl,\n dependencies: [ModelCache, ModelsFetcher, StorageOperations, CmsContext, ModelFieldCompression]\n});\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,qBAAqB;AAC5C,SAASC,qBAAqB,IAAIC,qBAAqB;AACvD,SAASC,UAAU,EAAEC,aAAa;AAClC,SACIC,+BAA+B,EAC/BC,qBAAqB,EACrBC,oBAAoB;AAExB,SAASC,UAAU,EAAEC,iBAAiB;AACtC,SAASC,qBAAqB;AAC9B,SAASC,uBAAuB;AAChC,SAASC,qBAAqB;AAC9B,SAASC,mBAAmB;AAE5B,SAASC,qBAAqB;;AAE9B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,yBAAyB,CAA4C;EAChEC,WAAWA,CACGC,UAAgC,EAChCC,aAAsC,EACtCC,iBAA8C,EAC9CC,UAAgC,EAChCC,qBAAsD,EACzE;IAAA,KALmBJ,UAAgC,GAAhCA,UAAgC;IAAA,KAChCC,aAAsC,GAAtCA,aAAsC;IAAA,KACtCC,iBAA8C,GAA9CA,iBAA8C;IAAA,KAC9CC,UAAgC,GAAhCA,UAAgC;IAAA,KAChCC,qBAAsD,GAAtDA,qBAAsD;EACxE;EAEH,MAAMC,OAAOA,CACTC,KAAe,EACfC,QAAkB,EACgC;IAClD,IAAI;MACA;MACA,IAAI;QACAd,qBAAqB,CAAC;UAAEa;QAAM,CAAC,CAAC;MACpC,CAAC,CAAC,OAAOE,KAAK,EAAE;QACZ,OAAOz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AAC,CAAC;QACN;;QAEA;QACA,MAAMV,mBAAmB,CAAC;UACtBuB,MAAM;UACNb,KAAK;UACLC,QAAQ;UACRoB,OAAO,EAAE,IAAI,CAACxB;QAClB,CAAC,CAAC;MACN,CAAC,CAAC,OAAOK,KAAK,EAAE;QACZ,OAAOzB,MAAM,CAAC0B,IAAI,CACd,IAAInB,oBAAoB,CAAC;UAAEoB,OAAO,EAAEF,KAAK,CAACE,OAAO;UAAEC,IAAI,EAAEH,KAAK,CAACG;QAAK,CAAC,CACzE,CAAC;MACL;MAEA,MAAMiB,MAAM,GAAG,MAAM,IAAI,CAACxB,qBAAqB,CAACyB,QAAQ,CAACvB,KAAK,CAACsB,MAAM,CAAC;;MAEtE;MACA,MAAM,IAAI,CAAC1B,iBAAiB,CAACiB,MAAM,CAACW,MAAM,CAAC;QACvCxB,KAAK,EAAE;UACH,GAAGA,KAAK;UACRsB;QACJ;MACJ,CAAC,CAAC;;MAEF;MACA,IAAI,CAAC5B,UAAU,CAAC+B,KAAK,CAAC,CAAC;MAEvB,OAAOhD,MAAM,CAACiD,EAAE,CAAC,CAAC;IACtB,CAAC,CAAC,OAAOxB,KAAK,EAAE;MACZ,OAAOzB,MAAM,CAAC0B,IAAI,CAAC,IAAIpB,qBAAqB,CAACmB,KAAc,CAAC,CAAC;IACjE;EACJ;AACJ;AAEA,OAAO,MAAMxB,qBAAqB,GAAGC,qBAAqB,CAACgD,oBAAoB,CAAC;EAC5EC,cAAc,EAAEpC,yBAAyB;EACzCqC,YAAY,EAAE,CAACjD,UAAU,EAAEC,aAAa,EAAEK,iBAAiB,EAAED,UAAU,EAAEM,qBAAqB;AAClG,CAAC,CAAC","ignoreList":[]}
@@ -4,6 +4,7 @@ import { PluginModelsProvider } from "../../../features/contentModel/shared/abst
4
4
  import { StorageOperations } from "../../../features/shared/abstractions.js";
5
5
  import { TenantContext } from "@webiny/api-core/features/tenancy/TenantContext/index.js";
6
6
  import type { CmsModel } from "../../../types/index.js";
7
+ import { ModelFieldCompression } from "../../../features/contentModel/ModelFieldCompression/index.js";
7
8
  /**
8
9
  * ModelsFetcherImpl - Implementation with multi-level caching.
9
10
  *
@@ -14,11 +15,12 @@ import type { CmsModel } from "../../../types/index.js";
14
15
  * 4. Final merged list is cached per tenant + identity
15
16
  */
16
17
  declare class ModelsFetcherImpl implements FetcherAbstraction.Interface {
17
- private modelCache;
18
- private pluginModelsProvider;
19
- private storageOperations;
20
- private tenantContext;
21
- constructor(modelCache: ModelCache.Interface, pluginModelsProvider: PluginModelsProvider.Interface, storageOperations: StorageOperations.Interface, tenantContext: TenantContext.Interface);
18
+ private readonly modelCache;
19
+ private readonly pluginModelsProvider;
20
+ private readonly storageOperations;
21
+ private readonly tenantContext;
22
+ private readonly modelFieldCompression;
23
+ constructor(modelCache: ModelCache.Interface, pluginModelsProvider: PluginModelsProvider.Interface, storageOperations: StorageOperations.Interface, tenantContext: TenantContext.Interface, modelFieldCompression: ModelFieldCompression.Interface);
22
24
  fetchAll(): Promise<Result<CmsModel[], FetcherAbstraction.Error>>;
23
25
  fetchById(modelId: string): Promise<Result<CmsModel, FetcherAbstraction.Error>>;
24
26
  private fetchAndMergeModels;
@@ -6,6 +6,8 @@ import { TenantContext } from "@webiny/api-core/features/tenancy/TenantContext/i
6
6
  import { ModelNotFoundError, ModelPersistenceError } from "../../../domain/contentModel/errors.js";
7
7
  import { createCacheKey } from "../../../utils/index.js";
8
8
  import { ensureTypeTag } from "../../../domain/contentModel/ensureTypeTag.js";
9
+ import { ModelFieldCompression } from "../ModelFieldCompression/index.js";
10
+
9
11
  /**
10
12
  * ModelsFetcherImpl - Implementation with multi-level caching.
11
13
  *
@@ -16,11 +18,12 @@ import { ensureTypeTag } from "../../../domain/contentModel/ensureTypeTag.js";
16
18
  * 4. Final merged list is cached per tenant + identity
17
19
  */
18
20
  class ModelsFetcherImpl {
19
- constructor(modelCache, pluginModelsProvider, storageOperations, tenantContext) {
21
+ constructor(modelCache, pluginModelsProvider, storageOperations, tenantContext, modelFieldCompression) {
20
22
  this.modelCache = modelCache;
21
23
  this.pluginModelsProvider = pluginModelsProvider;
22
24
  this.storageOperations = storageOperations;
23
25
  this.tenantContext = tenantContext;
26
+ this.modelFieldCompression = modelFieldCompression;
24
27
  }
25
28
  async fetchAll() {
26
29
  try {
@@ -61,11 +64,18 @@ class ModelsFetcherImpl {
61
64
  id: "storage"
62
65
  });
63
66
  const databaseModels = await this.modelCache.getOrSet(dbCacheKey, async () => {
64
- return this.storageOperations.models.list({
67
+ const models = await this.storageOperations.models.list({
65
68
  where: {
66
69
  tenant
67
70
  }
68
71
  });
72
+ return Promise.all(models.map(async model => {
73
+ const fields = await this.modelFieldCompression.decompress(model.fields);
74
+ return {
75
+ ...model,
76
+ fields
77
+ };
78
+ }));
69
79
  });
70
80
 
71
81
  // 2. Ensure type tags on database models
@@ -80,7 +90,7 @@ class ModelsFetcherImpl {
80
90
  }
81
91
  export const ModelsFetcher = FetcherAbstraction.createImplementation({
82
92
  implementation: ModelsFetcherImpl,
83
- dependencies: [ModelCache, PluginModelsProvider, StorageOperations, TenantContext]
93
+ dependencies: [ModelCache, PluginModelsProvider, StorageOperations, TenantContext, ModelFieldCompression]
84
94
  });
85
95
 
86
96
  //# sourceMappingURL=ModelsFetcher.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["Result","ModelCache","ModelsFetcher","FetcherAbstraction","PluginModelsProvider","StorageOperations","TenantContext","ModelNotFoundError","ModelPersistenceError","createCacheKey","ensureTypeTag","ModelsFetcherImpl","constructor","modelCache","pluginModelsProvider","storageOperations","tenantContext","fetchAll","tenant","getTenant","cacheKey","id","pluginModels","list","cached","getOrSet","fetchAndMergeModels","ok","error","fail","fetchById","modelId","result","isFail","model","value","find","m","dbCacheKey","databaseModels","models","where","taggedDatabaseModels","map","tags","createImplementation","implementation","dependencies"],"sources":["ModelsFetcher.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport {\n ModelCache,\n ModelsFetcher as FetcherAbstraction\n} from \"~/features/contentModel/shared/abstractions.js\";\nimport { PluginModelsProvider } from \"~/features/contentModel/shared/abstractions.js\";\nimport { StorageOperations } from \"~/features/shared/abstractions.js\";\nimport { TenantContext } from \"@webiny/api-core/features/tenancy/TenantContext/index.js\";\nimport { ModelNotFoundError, ModelPersistenceError } from \"~/domain/contentModel/errors.js\";\nimport { createCacheKey } from \"~/utils/index.js\";\nimport { ensureTypeTag } from \"~/domain/contentModel/ensureTypeTag.js\";\nimport type { CmsModel } from \"~/types/index.js\";\n\n/**\n * ModelsFetcherImpl - Implementation with multi-level caching.\n *\n * Caching strategy:\n * 1. Plugin models are cached per tenant (with access control applied by PluginModelsProvider)\n * 2. Database models are cached per tenant (raw from DB)\n * 3. Filtered database models are cached per tenant + identity (with access control applied)\n * 4. Final merged list is cached per tenant + identity\n */\nclass ModelsFetcherImpl implements FetcherAbstraction.Interface {\n public constructor(\n private modelCache: ModelCache.Interface,\n private pluginModelsProvider: PluginModelsProvider.Interface,\n private storageOperations: StorageOperations.Interface,\n private tenantContext: TenantContext.Interface\n ) {}\n\n async fetchAll(): Promise<Result<CmsModel[], FetcherAbstraction.Error>> {\n try {\n const tenant = this.tenantContext.getTenant();\n\n // Create a cache key based on tenant + identity\n const cacheKey = createCacheKey({\n tenant: tenant.id\n });\n\n // Fetch plugin models (with caching and access control)\n const pluginModels = await this.pluginModelsProvider.list(tenant.id);\n\n // Try to get from cache first\n const cached = await this.modelCache.getOrSet(cacheKey, async () => {\n return this.fetchAndMergeModels(tenant.id);\n });\n\n return Result.ok([...cached, ...pluginModels]);\n } catch (error) {\n return Result.fail(new ModelPersistenceError(error as Error));\n }\n }\n\n async fetchById(modelId: string): Promise<Result<CmsModel, FetcherAbstraction.Error>> {\n const result = await this.fetchAll();\n if (result.isFail()) {\n return Result.fail(new ModelPersistenceError(result.error));\n }\n\n const model = result.value.find(m => m.modelId === modelId);\n if (!model) {\n return Result.fail(new ModelNotFoundError(modelId));\n }\n\n return Result.ok(model);\n }\n\n private async fetchAndMergeModels(tenant: string): Promise<CmsModel[]> {\n // 1. Fetch database models (with caching)\n const dbCacheKey = createCacheKey({ tenant, id: \"storage\" });\n const databaseModels = await this.modelCache.getOrSet(dbCacheKey, async () => {\n return this.storageOperations.models.list({ where: { tenant } });\n });\n\n // 2. Ensure type tags on database models\n const taggedDatabaseModels = databaseModels.map(model => {\n model.tags = ensureTypeTag(model);\n return model;\n });\n\n // 3. Return merged models.\n return taggedDatabaseModels;\n }\n}\n\nexport const ModelsFetcher = FetcherAbstraction.createImplementation({\n implementation: ModelsFetcherImpl,\n dependencies: [ModelCache, PluginModelsProvider, StorageOperations, TenantContext]\n});\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,qBAAqB;AAC5C,SACIC,UAAU,EACVC,aAAa,IAAIC,kBAAkB;AAEvC,SAASC,oBAAoB;AAC7B,SAASC,iBAAiB;AAC1B,SAASC,aAAa,QAAQ,0DAA0D;AACxF,SAASC,kBAAkB,EAAEC,qBAAqB;AAClD,SAASC,cAAc;AACvB,SAASC,aAAa;AAGtB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,iBAAiB,CAAyC;EACrDC,WAAWA,CACNC,UAAgC,EAChCC,oBAAoD,EACpDC,iBAA8C,EAC9CC,aAAsC,EAChD;IAAA,KAJUH,UAAgC,GAAhCA,UAAgC;IAAA,KAChCC,oBAAoD,GAApDA,oBAAoD;IAAA,KACpDC,iBAA8C,GAA9CA,iBAA8C;IAAA,KAC9CC,aAAsC,GAAtCA,aAAsC;EAC/C;EAEH,MAAMC,QAAQA,CAAA,EAA0D;IACpE,IAAI;MACA,MAAMC,MAAM,GAAG,IAAI,CAACF,aAAa,CAACG,SAAS,CAAC,CAAC;;MAE7C;MACA,MAAMC,QAAQ,GAAGX,cAAc,CAAC;QAC5BS,MAAM,EAAEA,MAAM,CAACG;MACnB,CAAC,CAAC;;MAEF;MACA,MAAMC,YAAY,GAAG,MAAM,IAAI,CAACR,oBAAoB,CAACS,IAAI,C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AiB,CAACyB,MAAM,CAACjB,IAAI,CAAC;QAAEkB,KAAK,EAAE;UAAEvB;QAAO;MAAE,CAAC,CAAC;IACpE,CAAC,CAAC;;IAEF;IACA,MAAMwB,oBAAoB,GAAGH,cAAc,CAACI,GAAG,CAACT,KAAK,IAAI;MACrDA,KAAK,CAACU,IAAI,GAAGlC,aAAa,CAACwB,KAAK,CAAC;MACjC,OAAOA,KAAK;IAChB,CAAC,CAAC;;IAEF;IACA,OAAOQ,oBAAoB;EAC/B;AACJ;AAEA,OAAO,MAAMxC,aAAa,GAAGC,kBAAkB,CAAC0C,oBAAoB,CAAC;EACjEC,cAAc,EAAEnC,iBAAiB;EACjCoC,YAAY,EAAE,CAAC9C,UAAU,EAAEG,oBAAoB,EAAEC,iBAAiB,EAAEC,aAAa;AACrF,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["Result","ModelCache","ModelsFetcher","FetcherAbstraction","PluginModelsProvider","StorageOperations","TenantContext","ModelNotFoundError","ModelPersistenceError","createCacheKey","ensureTypeTag","ModelFieldCompression","ModelsFetcherImpl","constructor","modelCache","pluginModelsProvider","storageOperations","tenantContext","modelFieldCompression","fetchAll","tenant","getTenant","cacheKey","id","pluginModels","list","cached","getOrSet","fetchAndMergeModels","ok","error","fail","fetchById","modelId","result","isFail","model","value","find","m","dbCacheKey","databaseModels","models","where","Promise","all","map","fields","decompress","taggedDatabaseModels","tags","createImplementation","implementation","dependencies"],"sources":["ModelsFetcher.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport {\n ModelCache,\n ModelsFetcher as FetcherAbstraction\n} from \"~/features/contentModel/shared/abstractions.js\";\nimport { PluginModelsProvider } from \"~/features/contentModel/shared/abstractions.js\";\nimport { StorageOperations } from \"~/features/shared/abstractions.js\";\nimport { TenantContext } from \"@webiny/api-core/features/tenancy/TenantContext/index.js\";\nimport { ModelNotFoundError, ModelPersistenceError } from \"~/domain/contentModel/errors.js\";\nimport { createCacheKey } from \"~/utils/index.js\";\nimport { ensureTypeTag } from \"~/domain/contentModel/ensureTypeTag.js\";\nimport type { CmsModel } from \"~/types/index.js\";\nimport { ModelFieldCompression } from \"~/features/contentModel/ModelFieldCompression/index.js\";\n\n/**\n * ModelsFetcherImpl - Implementation with multi-level caching.\n *\n * Caching strategy:\n * 1. Plugin models are cached per tenant (with access control applied by PluginModelsProvider)\n * 2. Database models are cached per tenant (raw from DB)\n * 3. Filtered database models are cached per tenant + identity (with access control applied)\n * 4. Final merged list is cached per tenant + identity\n */\nclass ModelsFetcherImpl implements FetcherAbstraction.Interface {\n public constructor(\n private readonly modelCache: ModelCache.Interface,\n private readonly pluginModelsProvider: PluginModelsProvider.Interface,\n private readonly storageOperations: StorageOperations.Interface,\n private readonly tenantContext: TenantContext.Interface,\n private readonly modelFieldCompression: ModelFieldCompression.Interface\n ) {}\n\n async fetchAll(): Promise<Result<CmsModel[], FetcherAbstraction.Error>> {\n try {\n const tenant = this.tenantContext.getTenant();\n\n // Create a cache key based on tenant + identity\n const cacheKey = createCacheKey({\n tenant: tenant.id\n });\n\n // Fetch plugin models (with caching and access control)\n const pluginModels = await this.pluginModelsProvider.list(tenant.id);\n\n // Try to get from cache first\n const cached = await this.modelCache.getOrSet(cacheKey, async () => {\n return this.fetchAndMergeModels(tenant.id);\n });\n\n return Result.ok([...cached, ...pluginModels]);\n } catch (error) {\n return Result.fail(new ModelPersistenceError(error as Error));\n }\n }\n\n async fetchById(modelId: string): Promise<Result<CmsModel, FetcherAbstraction.Error>> {\n const result = await this.fetchAll();\n if (result.isFail()) {\n return Result.fail(new ModelPersistenceError(result.error));\n }\n\n const model = result.value.find(m => m.modelId === modelId);\n if (!model) {\n return Result.fail(new ModelNotFoundError(modelId));\n }\n\n return Result.ok(model);\n }\n\n private async fetchAndMergeModels(tenant: string): Promise<CmsModel[]> {\n // 1. Fetch database models (with caching)\n const dbCacheKey = createCacheKey({ tenant, id: \"storage\" });\n const databaseModels = await this.modelCache.getOrSet(dbCacheKey, async () => {\n const models = await this.storageOperations.models.list({ where: { tenant } });\n\n return Promise.all(\n models.map(async model => {\n const fields = await this.modelFieldCompression.decompress(model.fields);\n\n return {\n ...model,\n fields\n };\n })\n );\n });\n\n // 2. Ensure type tags on database models\n const taggedDatabaseModels = databaseModels.map(model => {\n model.tags = ensureTypeTag(model);\n return model;\n });\n\n // 3. Return merged models.\n return taggedDatabaseModels;\n }\n}\n\nexport const ModelsFetcher = FetcherAbstraction.createImplementation({\n implementation: ModelsFetcherImpl,\n dependencies: [\n ModelCache,\n PluginModelsProvider,\n StorageOperations,\n TenantContext,\n ModelFieldCompression\n ]\n});\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,qBAAqB;AAC5C,SACIC,UAAU,EACVC,aAAa,IAAIC,kBAAkB;AAEvC,SAASC,oBAAoB;AAC7B,SAASC,iBAAiB;AAC1B,SAASC,aAAa,QAAQ,0DAA0D;AACxF,SAASC,kBAAkB,EAAEC,qBAAqB;AAClD,SAASC,cAAc;AACvB,SAASC,aAAa;AAEtB,SAASC,qBAAqB;;AAE9B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,iBAAiB,CAAyC;EACrDC,WAAWA,CACGC,UAAgC,EAChCC,oBAAoD,EACpDC,iBAA8C,EAC9CC,aAAsC,EACtCC,qBAAsD,EACzE;IAAA,KALmBJ,UAAgC,GAAhCA,UAAgC;IAAA,KAChCC,oBAAoD,GAApDA,oBAAoD;IAAA,KACpDC,iBAA8C,GAA9CA,iBAA8C;IAAA,KAC9CC,aAAsC,GAAtCA,aAAsC;IAAA,KACtCC,qBAAsD,GAAtDA,qBAAsD;EACxE;EAEH,MAAMC,QAAQA,CAAA,EAA0D;IACpE,IAAI;MACA,MAAMC,MAAM,GAAG,IAAI,CAACH,aAAa,CAACI,SAAS,CAAC,CAAC;;MAE7C;MACA,MAAMC,QAAQ,GAAGb,cAAc,CAAC;QAC5BW,MAAM,EAAEA,MAAM,CAACG;MACnB,CAAC,CAAC;;MAEF;MAC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CAACa,QAAQ,CAACa,UAAU,EAAE,YAAY;MAC1E,MAAME,MAAM,GAAG,MAAM,IAAI,CAAC1B,iBAAiB,CAAC0B,MAAM,CAACjB,IAAI,CAAC;QAAEkB,KAAK,EAAE;UAAEvB;QAAO;MAAE,CAAC,CAAC;MAE9E,OAAOwB,OAAO,CAACC,GAAG,CACdH,MAAM,CAACI,GAAG,CAAC,MAAMV,KAAK,IAAI;QACtB,MAAMW,MAAM,GAAG,MAAM,IAAI,CAAC7B,qBAAqB,CAAC8B,UAAU,CAACZ,KAAK,CAACW,MAAM,CAAC;QAExE,OAAO;UACH,GAAGX,KAAK;UACRW;QACJ,CAAC;MACL,CAAC,CACL,CAAC;IACL,CAAC,CAAC;;IAEF;IACA,MAAME,oBAAoB,GAAGR,cAAc,CAACK,GAAG,CAACV,KAAK,IAAI;MACrDA,KAAK,CAACc,IAAI,GAAGxC,aAAa,CAAC0B,KAAK,CAAC;MACjC,OAAOA,KAAK;IAChB,CAAC,CAAC;;IAEF;IACA,OAAOa,oBAAoB;EAC/B;AACJ;AAEA,OAAO,MAAM/C,aAAa,GAAGC,kBAAkB,CAACgD,oBAAoB,CAAC;EACjEC,cAAc,EAAExC,iBAAiB;EACjCyC,YAAY,EAAE,CACVpD,UAAU,EACVG,oBAAoB,EACpBC,iBAAiB,EACjBC,aAAa,EACbK,qBAAqB;AAE7B,CAAC,CAAC","ignoreList":[]}
@@ -16,15 +16,35 @@ class DateTimeFieldBuilder extends DataFieldBuilder {
16
16
  this.config.settings.type = type;
17
17
  return this;
18
18
  }
19
+
20
+ /**
21
+ * Just a calendar date, no time, no timezone. Useful for things like birthdays, holidays, or due dates where the time of day doesn't matter.
22
+ * Example: 2026-04-30
23
+ */
19
24
  dateOnly() {
20
25
  return this.dateTimeType("date");
21
26
  }
27
+
28
+ /**
29
+ * Time in 24-hours format.
30
+ * Example: 19:35
31
+ */
22
32
  timeOnly() {
23
33
  return this.dateTimeType("time");
24
34
  }
35
+
36
+ /**
37
+ * This is an ISO 8601 datetime with an explicit timezone offset.
38
+ * Example: 2026-04-29T13:25:00+02:00
39
+ */
25
40
  withTimezone() {
26
41
  return this.dateTimeType("dateTimeWithTimezone");
27
42
  }
43
+
44
+ /**
45
+ * This is an ISO 8601 datetime in UTC (Zulu time). "Z" means "this is UTC, no offset."
46
+ * Example: 2026-04-30T13:25:00.000Z
47
+ */
28
48
  withoutTimezone() {
29
49
  return this.dateTimeType("dateTimeWithoutTimezone");
30
50
  }
@@ -1 +1 @@
1
- {"version":3,"names":["FieldType","DataFieldBuilder","DateTimeFieldBuilder","constructor","required","message","validation","name","settings","dateTimeType","type","config","dateOnly","timeOnly","withTimezone","withoutTimezone","dateGte","value","dateLte","DateTimeFieldTypeFactory","create","DateTimeFieldType","createImplementation","implementation","dependencies"],"sources":["DateTimeFieldType.ts"],"sourcesContent":["import { FieldType, type IFieldTypeFactory } from \"./abstractions.js\";\nimport { DataFieldBuilder } from \"./FieldBuilder.js\";\nimport { RequiredValidator, DateGteValidator, DateLteValidator } from \"./fieldTypeValidator.js\";\n\nexport type DateTimeType = \"date\" | \"time\" | \"dateTimeWithTimezone\" | \"dateTimeWithoutTimezone\";\n\nexport interface IDateTimeFieldBuilder\n extends DataFieldBuilder<\"datetime\">, RequiredValidator, DateGteValidator, DateLteValidator {\n dateTimeType(type: DateTimeType): this;\n dateOnly(): this;\n timeOnly(): this;\n withTimezone(): this;\n withoutTimezone(): this;\n}\n\nclass DateTimeFieldBuilder extends DataFieldBuilder<\"datetime\"> implements IDateTimeFieldBuilder {\n public constructor() {\n super(\"datetime\");\n }\n\n required(message?: string): this {\n return this.validation({\n name: \"required\",\n message: message || \"Value is required.\",\n settings: {}\n });\n }\n\n dateTimeType(type: DateTimeType): this {\n this.config.settings = this.config.settings || {};\n this.config.settings.type = type;\n return this;\n }\n\n dateOnly(): this {\n return this.dateTimeType(\"date\");\n }\n\n timeOnly(): this {\n return this.dateTimeType(\"time\");\n }\n\n withTimezone(): this {\n return this.dateTimeType(\"dateTimeWithTimezone\");\n }\n\n withoutTimezone(): this {\n return this.dateTimeType(\"dateTimeWithoutTimezone\");\n }\n\n dateGte(value: string, message?: string): this {\n const type = this.config.settings?.type || \"date\";\n return this.validation({\n name: \"dateGte\",\n message: message || \"Date/time is earlier than the provided one.\",\n settings: { value, type }\n });\n }\n\n dateLte(value: string, message?: string): this {\n const type = this.config.settings?.type || \"date\";\n return this.validation({\n name: \"dateLte\",\n message: message || \"Date/time is later than the provided one.\",\n settings: { value, type }\n });\n }\n}\n\nclass DateTimeFieldTypeFactory implements IFieldTypeFactory {\n readonly type = \"datetime\";\n\n create(): IDateTimeFieldBuilder {\n return new DateTimeFieldBuilder();\n }\n}\n\nexport const DateTimeFieldType = FieldType.createImplementation({\n implementation: DateTimeFieldTypeFactory,\n dependencies: []\n});\n\n// Module augmentation for TypeScript autocomplete\ndeclare module \"../abstractions.js\" {\n interface IFieldBuilderRegistry {\n datetime(): IDateTimeFieldBuilder;\n }\n}\n"],"mappings":"AAAA,SAASA,SAAS;AAClB,SAASC,gBAAgB;AAczB,MAAMC,oBAAoB,SAASD,gBAAgB,CAA8C;EACtFE,WAAWA,CAAA,EAAG;IACjB,KAAK,CAAC,UAAU,CAAC;EACrB;EAEAC,QAAQA,CAACC,OAAgB,EAAQ;IAC7B,OAAO,IAAI,CAACC,UAAU,CAAC;MACnBC,IAAI,EAAE,UAAU;MAChBF,OAAO,EAAEA,OAAO,IAAI,oBAAoB;MACxCG,QAAQ,EAAE,CAAC;IACf,CAAC,CAAC;EACN;EAEAC,YAAYA,CAACC,IAAkB,EAAQ;IACnC,IAAI,CAACC,MAAM,CAACH,QAAQ,GAAG,IAAI,CAACG,MAAM,CAACH,QAAQ,IAAI,CAAC,CAAC;IACjD,IAAI,CAACG,MAAM,CAACH,QAAQ,CAACE,IAAI,GAAGA,IAAI;IAChC,OAAO,IAAI;EACf;EAEAE,QAAQA,CAAA,EAAS;IACb,OAAO,IAAI,CAACH,YAAY,CAAC,MAAM,CAAC;EACpC;EAEAI,QAAQA,CAAA,EAAS;IACb,OAAO,IAAI,CAACJ,YAAY,CAAC,MAAM,CAAC;EACpC;EAEAK,YAAYA,CAAA,EAAS;IACjB,OAAO,IAAI,CAACL,YAAY,CAAC,sBAAsB,CAAC;EACpD;EAEAM,eAAeA,CAAA,EAAS;IACpB,OAAO,IAAI,CAACN,YAAY,CAAC,yBAAyB,CAAC;EACvD;EAEAO,OAAOA,CAACC,KAAa,EAAEZ,OAAgB,EAAQ;IAC3C,MAAMK,IAAI,GAAG,IAAI,CAACC,MAAM,CAACH,QAAQ,EAAEE,IAAI,IAAI,MAAM;IACjD,OAAO,IAAI,CAACJ,UAAU,CAAC;MACnBC,IAAI,EAAE,SAAS;MACfF,OAAO,EAAEA,OAAO,IAAI,6CAA6C;MACjEG,QAAQ,EAAE;QAAES,KAAK;QAAEP;MAAK;IAC5B,CAAC,CAAC;EACN;EAEAQ,OAAOA,CAACD,KAAa,EAAEZ,OAAgB,EAAQ;IAC3C,MAAMK,IAAI,GAAG,IAAI,CAACC,MAAM,CAACH,QAAQ,EAAEE,IAAI,IAAI,MAAM;IACjD,OAAO,IAAI,CAACJ,UAAU,CAAC;MACnBC,IAAI,EAAE,SAAS;MACfF,OAAO,EAAEA,OAAO,IAAI,2CAA2C;MAC/DG,QAAQ,EAAE;QAAES,KAAK;QAAEP;MAAK;IAC5B,CAAC,CAAC;EACN;AACJ;AAEA,MAAMS,wBAAwB,CAA8B;EAC/CT,IAAI,GAAG,UAAU;EAE1BU,MAAMA,CAAA,EAA0B;IAC5B,OAAO,IAAIlB,oBAAoB,CAAC,CAAC;EACrC;AACJ;AAEA,OAAO,MAAMmB,iBAAiB,GAAGrB,SAAS,CAACsB,oBAAoB,CAAC;EAC5DC,cAAc,EAAEJ,wBAAwB;EACxCK,YAAY,EAAE;AAClB,CAAC,CAAC;;AAEF","ignoreList":[]}
1
+ {"version":3,"names":["FieldType","DataFieldBuilder","DateTimeFieldBuilder","constructor","required","message","validation","name","settings","dateTimeType","type","config","dateOnly","timeOnly","withTimezone","withoutTimezone","dateGte","value","dateLte","DateTimeFieldTypeFactory","create","DateTimeFieldType","createImplementation","implementation","dependencies"],"sources":["DateTimeFieldType.ts"],"sourcesContent":["import { FieldType, type IFieldTypeFactory } from \"./abstractions.js\";\nimport { DataFieldBuilder } from \"./FieldBuilder.js\";\nimport { RequiredValidator, DateGteValidator, DateLteValidator } from \"./fieldTypeValidator.js\";\n\nexport type DateTimeType = \"date\" | \"time\" | \"dateTimeWithTimezone\" | \"dateTimeWithoutTimezone\";\n\nexport interface IDateTimeFieldBuilder\n extends DataFieldBuilder<\"datetime\">, RequiredValidator, DateGteValidator, DateLteValidator {\n dateTimeType(type: DateTimeType): this;\n dateOnly(): this;\n timeOnly(): this;\n withTimezone(): this;\n withoutTimezone(): this;\n}\n\nclass DateTimeFieldBuilder extends DataFieldBuilder<\"datetime\"> implements IDateTimeFieldBuilder {\n public constructor() {\n super(\"datetime\");\n }\n\n required(message?: string): this {\n return this.validation({\n name: \"required\",\n message: message || \"Value is required.\",\n settings: {}\n });\n }\n\n dateTimeType(type: DateTimeType): this {\n this.config.settings = this.config.settings || {};\n this.config.settings.type = type;\n return this;\n }\n\n /**\n * Just a calendar date, no time, no timezone. Useful for things like birthdays, holidays, or due dates where the time of day doesn't matter.\n * Example: 2026-04-30\n */\n dateOnly(): this {\n return this.dateTimeType(\"date\");\n }\n\n /**\n * Time in 24-hours format.\n * Example: 19:35\n */\n timeOnly(): this {\n return this.dateTimeType(\"time\");\n }\n\n /**\n * This is an ISO 8601 datetime with an explicit timezone offset.\n * Example: 2026-04-29T13:25:00+02:00\n */\n withTimezone(): this {\n return this.dateTimeType(\"dateTimeWithTimezone\");\n }\n\n /**\n * This is an ISO 8601 datetime in UTC (Zulu time). \"Z\" means \"this is UTC, no offset.\"\n * Example: 2026-04-30T13:25:00.000Z\n */\n withoutTimezone(): this {\n return this.dateTimeType(\"dateTimeWithoutTimezone\");\n }\n\n dateGte(value: string, message?: string): this {\n const type = this.config.settings?.type || \"date\";\n return this.validation({\n name: \"dateGte\",\n message: message || \"Date/time is earlier than the provided one.\",\n settings: { value, type }\n });\n }\n\n dateLte(value: string, message?: string): this {\n const type = this.config.settings?.type || \"date\";\n return this.validation({\n name: \"dateLte\",\n message: message || \"Date/time is later than the provided one.\",\n settings: { value, type }\n });\n }\n}\n\nclass DateTimeFieldTypeFactory implements IFieldTypeFactory {\n readonly type = \"datetime\";\n\n create(): IDateTimeFieldBuilder {\n return new DateTimeFieldBuilder();\n }\n}\n\nexport const DateTimeFieldType = FieldType.createImplementation({\n implementation: DateTimeFieldTypeFactory,\n dependencies: []\n});\n\n// Module augmentation for TypeScript autocomplete\ndeclare module \"../abstractions.js\" {\n interface IFieldBuilderRegistry {\n datetime(): IDateTimeFieldBuilder;\n }\n}\n"],"mappings":"AAAA,SAASA,SAAS;AAClB,SAASC,gBAAgB;AAczB,MAAMC,oBAAoB,SAASD,gBAAgB,CAA8C;EACtFE,WAAWA,CAAA,EAAG;IACjB,KAAK,CAAC,UAAU,CAAC;EACrB;EAEAC,QAAQA,CAACC,OAAgB,EAAQ;IAC7B,OAAO,IAAI,CAACC,UAAU,CAAC;MACnBC,IAAI,EAAE,UAAU;MAChBF,OAAO,EAAEA,OAAO,IAAI,oBAAoB;MACxCG,QAAQ,EAAE,CAAC;IACf,CAAC,CAAC;EACN;EAEAC,YAAYA,CAACC,IAAkB,EAAQ;IACnC,IAAI,CAACC,MAAM,CAACH,QAAQ,GAAG,IAAI,CAACG,MAAM,CAACH,QAAQ,IAAI,CAAC,CAAC;IACjD,IAAI,CAACG,MAAM,CAACH,QAAQ,CAACE,IAAI,GAAGA,IAAI;IAChC,OAAO,IAAI;EACf;;EAEA;AACJ;AACA;AACA;EACIE,QAAQA,CAAA,EAAS;IACb,OAAO,IAAI,CAACH,YAAY,CAAC,MAAM,CAAC;EACpC;;EAEA;AACJ;AACA;AACA;EACII,QAAQA,CAAA,EAAS;IACb,OAAO,IAAI,CAACJ,YAAY,CAAC,MAAM,CAAC;EACpC;;EAEA;AACJ;AACA;AACA;EACIK,YAAYA,CAAA,EAAS;IACjB,OAAO,IAAI,CAACL,YAAY,CAAC,sBAAsB,CAAC;EACpD;;EAEA;AACJ;AACA;AACA;EACIM,eAAeA,CAAA,EAAS;IACpB,OAAO,IAAI,CAACN,YAAY,CAAC,yBAAyB,CAAC;EACvD;EAEAO,OAAOA,CAACC,KAAa,EAAEZ,OAAgB,EAAQ;IAC3C,MAAMK,IAAI,GAAG,IAAI,CAACC,MAAM,CAACH,QAAQ,EAAEE,IAAI,IAAI,MAAM;IACjD,OAAO,IAAI,CAACJ,UAAU,CAAC;MACnBC,IAAI,EAAE,SAAS;MACfF,OAAO,EAAEA,OAAO,IAAI,6CAA6C;MACjEG,QAAQ,EAAE;QAAES,KAAK;QAAEP;MAAK;IAC5B,CAAC,CAAC;EACN;EAEAQ,OAAOA,CAACD,KAAa,EAAEZ,OAAgB,EAAQ;IAC3C,MAAMK,IAAI,GAAG,IAAI,CAACC,MAAM,CAACH,QAAQ,EAAEE,IAAI,IAAI,MAAM;IACjD,OAAO,IAAI,CAACJ,UAAU,CAAC;MACnBC,IAAI,EAAE,SAAS;MACfF,OAAO,EAAEA,OAAO,IAAI,2CAA2C;MAC/DG,QAAQ,EAAE;QAAES,KAAK;QAAEP;MAAK;IAC5B,CAAC,CAAC;EACN;AACJ;AAEA,MAAMS,wBAAwB,CAA8B;EAC/CT,IAAI,GAAG,UAAU;EAE1BU,MAAMA,CAAA,EAA0B;IAC5B,OAAO,IAAIlB,oBAAoB,CAAC,CAAC;EACrC;AACJ;AAEA,OAAO,MAAMmB,iBAAiB,GAAGrB,SAAS,CAACsB,oBAAoB,CAAC;EAC5DC,cAAc,EAAEJ,wBAAwB;EACxCK,YAAY,EAAE;AAClB,CAAC,CAAC;;AAEF","ignoreList":[]}
@@ -36,6 +36,15 @@ export const createCreateEntryResolver = () => {
36
36
  data
37
37
  }
38
38
  });
39
+ if (result.errors && result.errors.length > 0) {
40
+ return {
41
+ data: null,
42
+ error: {
43
+ message: result.errors.map(e => e.message).join("; "),
44
+ code: "CREATE_ENTRY_ERROR"
45
+ }
46
+ };
47
+ }
39
48
  const operationName = `create${model.singularApiName}`;
40
49
  return result.data?.[operationName] || {
41
50
  data: null,
@@ -1 +1 @@
1
- {"version":3,"names":["getModel","getErrorMessage","buildFieldsSelection","createCreateEntryResolver","args","context","modelId","data","fields","model","apiType","executeSchema","cms","getExecutableSchema","fieldsSelection","query","singularApiName","result","variables","operationName","error","message","code"],"sources":["createEntryResolver.ts"],"sourcesContent":["import type { CmsContext } from \"~/types/index.js\";\nimport type { ApiEndpoint } from \"~/types/index.js\";\nimport type { ExecutionResult } from \"graphql\";\nimport { getModel, getErrorMessage, buildFieldsSelection } from \"./helpers.js\";\n\nexport interface CreateEntryArgs {\n modelId: string;\n data: Record<string, unknown>;\n fields: string[];\n}\n\nexport const createCreateEntryResolver = () => {\n return async ({ args, context }: { args: CreateEntryArgs; context: CmsContext }) => {\n const { modelId, data, fields } = args;\n\n try {\n const model = await getModel(context, modelId);\n\n // Use manage API for creating entries.\n const apiType: ApiEndpoint = \"manage\";\n const executeSchema = await context.cms.getExecutableSchema(apiType);\n\n const fieldsSelection = buildFieldsSelection(fields);\n\n const query = /* GraphQL */ `\n mutation Create${model.singularApiName}($data: ${model.singularApiName}Input!) {\n create${model.singularApiName}(data: $data) {\n data {\n ${fieldsSelection}\n }\n error {\n message\n code\n data\n }\n }\n }\n `;\n\n const result = (await executeSchema({\n query,\n variables: { data }\n })) as ExecutionResult;\n\n const operationName = `create${model.singularApiName}`;\n return result.data?.[operationName] || { data: null, error: null };\n } catch (error) {\n return {\n data: null,\n error: {\n message: getErrorMessage(error, \"Failed to create entry\"),\n code: \"CREATE_ENTRY_ERROR\"\n }\n };\n }\n };\n};\n"],"mappings":"AAGA,SAASA,QAAQ,EAAEC,eAAe,EAAEC,oBAAoB;AAQxD,OAAO,MAAMC,yBAAyB,GAAGA,CAAA,KAAM;EAC3C,OAAO,OAAO;IAAEC,IAAI;IAAEC;EAAwD,CAAC,KAAK;IAChF,MAAM;MAAEC,OAAO;MAAEC,IAAI;MAAEC;IAAO,CAAC,GAAGJ,IAAI;IAEtC,IAAI;MACA,MAAMK,KAAK,GAAG,MAAMT,QAAQ,CAACK,OAAO,EAAEC,OAAO,CAAC;;MAE9C;MACA,MAAMI,OAAoB,GAAG,QAAQ;MACrC,MAAMC,aAAa,GAAG,MAAMN,OAAO,CAACO,GAAG,CAACC,mBAAmB,CAACH,OAAO,CAAC;MAEpE,MAAMI,eAAe,GAAGZ,oBAAoB,CAACM,MAAM,CAAC;MAEpD,MAAMO,KAAK,GAAG,aAAc;AACxC,iCAAiCN,KAAK,CAACO,eAAe,WAAWP,KAAK,CAACO,eAAe;AACtF,4BAA4BP,KAAK,CAACO,eAAe;AACjD;AACA,8BAA8BF,eAAe;AAC7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;MAED,MAAMG,MAAM,GAAI,MAAMN,aAAa,CAAC;QAChCI,KAAK;QACLG,SAAS,EAAE;UAAEX;QAAK;MACtB,CAAC,CAAqB;MAEtB,MAAMY,aAAa,GAAG,SAASV,KAAK,CAACO,eAAe,EAAE;MACtD,OAAOC,MAAM,CAACV,IAAI,GAAGY,aAAa,CAAC,IAAI;QAAEZ,IAAI,EAAE,IAAI;QAAEa,KAAK,EAAE;MAAK,CAAC;IACtE,CAAC,CAAC,OAAOA,KAAK,EAAE;MACZ,OAAO;QACHb,IAAI,EAAE,IAAI;QACVa,KAAK,EAAE;UACHC,OAAO,EAAEpB,eAAe,CAACmB,KAAK,EAAE,wBAAwB,CAAC;UACzDE,IAAI,EAAE;QACV;MACJ,CAAC;IACL;EACJ,CAAC;AACL,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["getModel","getErrorMessage","buildFieldsSelection","createCreateEntryResolver","args","context","modelId","data","fields","model","apiType","executeSchema","cms","getExecutableSchema","fieldsSelection","query","singularApiName","result","variables","errors","length","error","message","map","e","join","code","operationName"],"sources":["createEntryResolver.ts"],"sourcesContent":["import type { CmsContext } from \"~/types/index.js\";\nimport type { ApiEndpoint } from \"~/types/index.js\";\nimport type { ExecutionResult } from \"graphql\";\nimport { getModel, getErrorMessage, buildFieldsSelection } from \"./helpers.js\";\n\nexport interface CreateEntryArgs {\n modelId: string;\n data: Record<string, unknown>;\n fields: string[];\n}\n\nexport const createCreateEntryResolver = () => {\n return async ({ args, context }: { args: CreateEntryArgs; context: CmsContext }) => {\n const { modelId, data, fields } = args;\n\n try {\n const model = await getModel(context, modelId);\n\n // Use manage API for creating entries.\n const apiType: ApiEndpoint = \"manage\";\n const executeSchema = await context.cms.getExecutableSchema(apiType);\n\n const fieldsSelection = buildFieldsSelection(fields);\n\n const query = /* GraphQL */ `\n mutation Create${model.singularApiName}($data: ${model.singularApiName}Input!) {\n create${model.singularApiName}(data: $data) {\n data {\n ${fieldsSelection}\n }\n error {\n message\n code\n data\n }\n }\n }\n `;\n\n const result = (await executeSchema({\n query,\n variables: { data }\n })) as ExecutionResult;\n\n if (result.errors && result.errors.length > 0) {\n return {\n data: null,\n error: {\n message: result.errors.map(e => e.message).join(\"; \"),\n code: \"CREATE_ENTRY_ERROR\"\n }\n };\n }\n\n const operationName = `create${model.singularApiName}`;\n return result.data?.[operationName] || { data: null, error: null };\n } catch (error) {\n return {\n data: null,\n error: {\n message: getErrorMessage(error, \"Failed to create entry\"),\n code: \"CREATE_ENTRY_ERROR\"\n }\n };\n }\n };\n};\n"],"mappings":"AAGA,SAASA,QAAQ,EAAEC,eAAe,EAAEC,oBAAoB;AAQxD,OAAO,MAAMC,yBAAyB,GAAGA,CAAA,KAAM;EAC3C,OAAO,OAAO;IAAEC,IAAI;IAAEC;EAAwD,CAAC,KAAK;IAChF,MAAM;MAAEC,OAAO;MAAEC,IAAI;MAAEC;IAAO,CAAC,GAAGJ,IAAI;IAEtC,IAAI;MACA,MAAMK,KAAK,GAAG,MAAMT,QAAQ,CAACK,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,15 @@ export const createDeleteEntryRevisionResolver = () => {
36
36
  }
37
37
  }
38
38
  });
39
+ if (result.errors && result.errors.length > 0) {
40
+ return {
41
+ data: false,
42
+ error: {
43
+ message: result.errors.map(e => e.message).join("; "),
44
+ code: "DELETE_ENTRY_ERROR"
45
+ }
46
+ };
47
+ }
39
48
  const operationName = `delete${model.singularApiName}`;
40
49
  return result.data?.[operationName] || {
41
50
  data: false,
@@ -1 +1 @@
1
- {"version":3,"names":["getModel","getErrorMessage","createDeleteEntryRevisionResolver","args","context","modelId","revisionId","permanent","model","apiType","executeSchema","cms","getExecutableSchema","query","singularApiName","result","variables","options","permanently","operationName","data","error","message","code"],"sources":["deleteEntryResolver.ts"],"sourcesContent":["import type { CmsContext } from \"~/types/index.js\";\nimport type { ApiEndpoint } from \"~/types/index.js\";\nimport type { ExecutionResult } from \"graphql\";\nimport { getModel, getErrorMessage } from \"./helpers.js\";\n\nexport interface DeleteEntryRevisionArgs {\n modelId: string;\n revisionId: string;\n permanent?: boolean;\n}\n\nexport const createDeleteEntryRevisionResolver = () => {\n return async ({ args, context }: { args: DeleteEntryRevisionArgs; context: CmsContext }) => {\n const { modelId, revisionId, permanent = false } = args;\n\n try {\n const model = await getModel(context, modelId);\n\n // Use manage API for deleting entries.\n const apiType: ApiEndpoint = \"manage\";\n const executeSchema = await context.cms.getExecutableSchema(apiType);\n\n const query = /* GraphQL */ `\n mutation Delete${model.singularApiName}($revisionId: ID!, $options: CmsDeleteEntryOptions) {\n delete${model.singularApiName}(revision: $revisionId, options: $options) {\n data\n error {\n message\n code\n data\n }\n }\n }\n `;\n\n const result = (await executeSchema({\n query,\n variables: {\n revisionId,\n options: { permanently: permanent }\n }\n })) as ExecutionResult;\n\n const operationName = `delete${model.singularApiName}`;\n return result.data?.[operationName] || { data: false, error: null };\n } catch (error) {\n return {\n data: false,\n error: {\n message: getErrorMessage(error, \"Failed to delete entry\"),\n code: \"DELETE_ENTRY_ERROR\"\n }\n };\n }\n };\n};\n"],"mappings":"AAGA,SAASA,QAAQ,EAAEC,eAAe;AAQlC,OAAO,MAAMC,iCAAiC,GAAGA,CAAA,KAAM;EACnD,OAAO,OAAO;IAAEC,IAAI;IAAEC;EAAgE,CAAC,KAAK;IACxF,MAAM;MAAEC,OAAO;MAAEC,UAAU;MAAEC,SAAS,GAAG;IAAM,CAAC,GAAGJ,IAAI;IAEvD,IAAI;MACA,MAAMK,KAAK,GAAG,MAAMR,QAAQ,CAACI,OAAO,EAAEC,OAAO,CAAC;;MAE9C;MACA,MAAMI,OAAoB,GAAG,QAAQ;MACrC,MAAMC,aAAa,GAAG,MAAMN,OAAO,CAACO,GAAG,CAACC,mBAAmB,CAACH,OAAO,CAAC;MAEpE,MAAMI,KAAK,GAAG,aAAc;AACxC,iCAAiCL,KAAK,CAACM,eAAe;AACtD,4BAA4BN,KAAK,CAACM,eAAe;AACjD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;MAED,MAAMC,MAAM,GAAI,MAAML,aAAa,CAAC;QAChCG,KAAK;QACLG,SAAS,EAAE;UACPV,UAAU;UACVW,OAAO,EAAE;YAAEC,WAAW,EAAEX;UAAU;QACtC;MACJ,CAAC,CAAqB;MAEtB,MAAMY,aAAa,GAAG,SAASX,KAAK,CAACM,eAAe,EAAE;MACtD,OAAOC,MAAM,CAACK,IAAI,GAAGD,aAAa,CAAC,IAAI;QAAEC,IAAI,EAAE,KAAK;QAAEC,KAAK,EAAE;MAAK,CAAC;IACvE,CAAC,CAAC,OAAOA,KAAK,EAAE;MACZ,OAAO;QACHD,IAAI,EAAE,KAAK;QACXC,KAAK,EAAE;UACHC,OAAO,EAAErB,eAAe,CAACoB,KAAK,EAAE,wBAAwB,CAAC;UACzDE,IAAI,EAAE;QACV;MACJ,CAAC;IACL;EACJ,CAAC;AACL,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["getModel","getErrorMessage","createDeleteEntryRevisionResolver","args","context","modelId","revisionId","permanent","model","apiType","executeSchema","cms","getExecutableSchema","query","singularApiName","result","variables","options","permanently","errors","length","data","error","message","map","e","join","code","operationName"],"sources":["deleteEntryResolver.ts"],"sourcesContent":["import type { CmsContext } from \"~/types/index.js\";\nimport type { ApiEndpoint } from \"~/types/index.js\";\nimport type { ExecutionResult } from \"graphql\";\nimport { getModel, getErrorMessage } from \"./helpers.js\";\n\nexport interface DeleteEntryRevisionArgs {\n modelId: string;\n revisionId: string;\n permanent?: boolean;\n}\n\nexport const createDeleteEntryRevisionResolver = () => {\n return async ({ args, context }: { args: DeleteEntryRevisionArgs; context: CmsContext }) => {\n const { modelId, revisionId, permanent = false } = args;\n\n try {\n const model = await getModel(context, modelId);\n\n // Use manage API for deleting entries.\n const apiType: ApiEndpoint = \"manage\";\n const executeSchema = await context.cms.getExecutableSchema(apiType);\n\n const query = /* GraphQL */ `\n mutation Delete${model.singularApiName}($revisionId: ID!, $options: CmsDeleteEntryOptions) {\n delete${model.singularApiName}(revision: $revisionId, options: $options) {\n data\n error {\n message\n code\n data\n }\n }\n }\n `;\n\n const result = (await executeSchema({\n query,\n variables: {\n revisionId,\n options: { permanently: permanent }\n }\n })) as ExecutionResult;\n\n if (result.errors && result.errors.length > 0) {\n return {\n data: false,\n error: {\n message: result.errors.map(e => e.message).join(\"; \"),\n code: \"DELETE_ENTRY_ERROR\"\n }\n };\n }\n\n const operationName = `delete${model.singularApiName}`;\n return result.data?.[operationName] || { data: false, error: null };\n } catch (error) {\n return {\n data: false,\n error: {\n message: getErrorMessage(error, \"Failed to delete entry\"),\n code: \"DELETE_ENTRY_ERROR\"\n }\n };\n }\n };\n};\n"],"mappings":"AAGA,SAASA,QAAQ,EAAEC,eAAe;AAQlC,OAAO,MAAMC,iCAAiC,GAAGA,CAAA,KAAM;EACnD,OAAO,OAAO;IAAEC,IAAI;IAAEC;EAAgE,CAAC,KAAK;IACxF,MAAM;MAAEC,OAAO;MAAEC,UAAU;MAAEC,SAAS,GAAG;IAAM,CAAC,GAAGJ,IAAI;IAEvD,IAAI;MACA,M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() => {
38
38
  where
39
39
  }
40
40
  });
41
+ if (result.errors && result.errors.length > 0) {
42
+ return {
43
+ data: null,
44
+ error: {
45
+ message: result.errors.map(e => e.message).join("; "),
46
+ code: "GET_ENTRY_ERROR"
47
+ }
48
+ };
49
+ }
41
50
  const operationName = `get${model.singularApiName}`;
42
51
  return result.data?.[operationName] || {
43
52
  data: null,
@@ -1 +1 @@
1
- {"version":3,"names":["getModel","getErrorMessage","buildFieldsSelection","createGetEntryResolver","args","context","modelId","where","fields","preview","model","apiType","executeSchema","cms","getExecutableSchema","fieldsSelection","query","singularApiName","result","variables","operationName","data","error","message","code"],"sources":["getEntryResolver.ts"],"sourcesContent":["import type { CmsContext } from \"~/types/index.js\";\nimport type { ApiEndpoint } from \"~/types/index.js\";\nimport type { ExecutionResult } from \"graphql\";\nimport { getModel, getErrorMessage, buildFieldsSelection } from \"./helpers.js\";\n\nexport interface GetEntryArgs {\n modelId: string;\n where: Record<string, unknown>;\n fields: string[];\n preview?: boolean;\n}\n\nexport const createGetEntryResolver = () => {\n return async ({ args, context }: { args: GetEntryArgs; context: CmsContext }) => {\n const { modelId, where, fields, preview = false } = args;\n\n try {\n const model = await getModel(context, modelId);\n\n // Determine which API to use based on the preview flag.\n // preview=true -> preview API, preview=false -> read API\n const apiType: ApiEndpoint = preview ? \"preview\" : \"read\";\n const executeSchema = await context.cms.getExecutableSchema(apiType);\n\n const fieldsSelection = buildFieldsSelection(fields);\n\n const query = /* GraphQL */ `\n query Get${model.singularApiName}($where: ${model.singularApiName}GetWhereInput!) {\n get${model.singularApiName}(where: $where) {\n data {\n ${fieldsSelection}\n }\n error {\n message\n code\n data\n }\n }\n }\n `;\n\n const result = (await executeSchema({\n query,\n variables: { where }\n })) as ExecutionResult;\n\n const operationName = `get${model.singularApiName}`;\n return result.data?.[operationName] || { data: null, error: null };\n } catch (error) {\n return {\n data: null,\n error: {\n message: getErrorMessage(error, \"Failed to get entry\"),\n code: \"GET_ENTRY_ERROR\"\n }\n };\n }\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ACL;EACJ,CAAC;AACL,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["getModel","getErrorMessage","buildFieldsSelection","createGetEntryResolver","args","context","modelId","where","fields","preview","model","apiType","executeSchema","cms","getExecutableSchema","fieldsSelection","query","singularApiName","result","variables","errors","length","data","error","message","map","e","join","code","operationName"],"sources":["getEntryResolver.ts"],"sourcesContent":["import type { CmsContext } from \"~/types/index.js\";\nimport type { ApiEndpoint } from \"~/types/index.js\";\nimport type { ExecutionResult } from \"graphql\";\nimport { getModel, getErrorMessage, buildFieldsSelection } from \"./helpers.js\";\n\nexport interface GetEntryArgs {\n modelId: string;\n where: Record<string, unknown>;\n fields: string[];\n preview?: boolean;\n}\n\nexport const createGetEntryResolver = () => {\n return async ({ args, context }: { args: GetEntryArgs; context: CmsContext }) => {\n const { modelId, where, fields, preview = false } = args;\n\n try {\n const model = await getModel(context, modelId);\n\n // Determine which API to use based on the preview flag.\n // preview=true -> preview API, preview=false -> read API\n const apiType: ApiEndpoint = preview ? \"preview\" : \"read\";\n const executeSchema = await context.cms.getExecutableSchema(apiType);\n\n const fieldsSelection = buildFieldsSelection(fields);\n\n const query = /* GraphQL */ `\n query Get${model.singularApiName}($where: ${model.singularApiName}GetWhereInput!) {\n get${model.singularApiName}(where: $where) {\n data {\n ${fieldsSelection}\n }\n error {\n message\n code\n data\n }\n }\n }\n `;\n\n const result = (await executeSchema({\n query,\n variables: { where }\n })) as ExecutionResult;\n\n if (result.errors && result.errors.length > 0) {\n return {\n data: null,\n error: {\n message: result.errors.map(e => e.message).join(\"; \"),\n code: \"GET_ENTRY_ERROR\"\n }\n };\n }\n\n const operationName = `get${model.singularApiName}`;\n return result.data?.[operationName] || { data: null, error: null };\n } catch (error) {\n return {\n data: null,\n error: {\n message: getErrorMessage(error, \"Failed to get entry\"),\n code: \"GET_ENTRY_ERROR\"\n }\n };\n }\n };\n};\n"],"mappings":"AAGA,SAASA,QAAQ,EAAEC,eAAe,EAAEC,oBAAoB;AASxD,OAAO,M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,IAAI;QAAEC,KAAK,EAAE;MAAK,CAAC;IACtE,CAAC,CAAC,OAAOA,KAAK,EAAE;MACZ,OAAO;QACHD,IAAI,EAAE,IAAI;QACVC,KAAK,EAAE;UACHC,OAAO,EAAEvB,eAAe,CAACsB,KAAK,EAAE,qBAAqB,CAAC;UACtDK,IAAI,EAAE;QACV;MACJ,CAAC;IACL;EACJ,CAAC;AACL,CAAC","ignoreList":[]}
@@ -71,6 +71,20 @@ export const createListEntriesResolver = () => {
71
71
  search
72
72
  }
73
73
  });
74
+ if (result.errors && result.errors.length > 0) {
75
+ return {
76
+ data: [],
77
+ meta: {
78
+ cursor: null,
79
+ hasMoreItems: false,
80
+ totalCount: 0
81
+ },
82
+ error: {
83
+ message: result.errors.map(e => e.message).join("; "),
84
+ code: "LIST_ENTRIES_ERROR"
85
+ }
86
+ };
87
+ }
74
88
  const operationName = `list${model.pluralApiName}`;
75
89
  return result.data?.[operationName] || {
76
90
  data: [],
@@ -1 +1 @@
1
- {"version":3,"names":["getModel","getErrorMessage","buildFieldsSelection","transformSortToArray","transformWhereToNested","createListEntriesResolver","args","context","modelId","where","sort","limit","after","search","fields","preview","model","apiType","executeSchema","cms","getExecutableSchema","fieldsSelection","transformedSort","transformedWhere","query","pluralApiName","singularApiName","result","variables","operationName","data","meta","cursor","hasMoreItems","totalCount","error","message","code"],"sources":["listEntriesResolver.ts"],"sourcesContent":["import type { CmsContext } from \"~/types/index.js\";\nimport type { ApiEndpoint } from \"~/types/index.js\";\nimport type { ExecutionResult } from \"graphql\";\nimport {\n getModel,\n getErrorMessage,\n buildFieldsSelection,\n transformSortToArray,\n transformWhereToNested\n} from \"./helpers.js\";\n\nexport interface ListEntriesArgs {\n modelId: string;\n where?: Record<string, unknown>;\n sort?: Record<string, unknown> | string[];\n limit?: number;\n after?: string;\n search?: string;\n fields: string[];\n preview?: boolean;\n}\n\nexport const createListEntriesResolver = () => {\n return async ({ args, context }: { args: ListEntriesArgs; context: CmsContext }) => {\n const { modelId, where, sort, limit, after, search, fields, preview = false } = args;\n\n try {\n const model = await getModel(context, modelId);\n\n // Determine which API to use based on the preview flag.\n // preview=true -> preview API, preview=false -> read API\n const apiType: ApiEndpoint = preview ? \"preview\" : \"read\";\n const executeSchema = await context.cms.getExecutableSchema(apiType);\n\n const fieldsSelection = buildFieldsSelection(fields);\n\n // Transform sort to array format expected by the underlying GraphQL schema.\n // Handles both object format {createdOn: \"desc\"} and array format [\"createdOn_DESC\"].\n const transformedSort = transformSortToArray(sort);\n\n // Transform dot-notation where keys (e.g. \"values.name\") into nested objects\n // (e.g. { values: { name: ... } }) so they match the typed ListWhereInput.\n const transformedWhere = transformWhereToNested(where);\n\n const query = /* GraphQL */ `\n query List${model.pluralApiName}(\n $where: ${model.singularApiName}ListWhereInput\n $sort: [${model.singularApiName}ListSorter!]\n $limit: Int\n $after: String\n $search: String\n ) {\n list${model.pluralApiName}(\n where: $where\n sort: $sort\n limit: $limit\n after: $after\n search: $search\n ) {\n data {\n ${fieldsSelection}\n }\n meta {\n cursor\n hasMoreItems\n totalCount\n }\n error {\n message\n code\n data\n }\n }\n }\n `;\n\n const result = (await executeSchema({\n query,\n variables: { where: transformedWhere, sort: transformedSort, limit, after, search }\n })) as ExecutionResult;\n\n const operationName = `list${model.pluralApiName}`;\n return (\n result.data?.[operationName] || {\n data: [],\n meta: { cursor: null, hasMoreItems: false, totalCount: 0 },\n error: null\n }\n );\n } catch (error) {\n return {\n data: [],\n meta: { cursor: null, hasMoreItems: false, totalCount: 0 },\n error: {\n message: getErrorMessage(error, \"Failed to list entries\"),\n code: \"LIST_ENTRIES_ERROR\"\n }\n };\n }\n };\n};\n"],"mappings":"AAGA,SACIA,QAAQ,EACRC,eAAe,EACfC,oBAAoB,EACpBC,oBAAoB,EACpBC,sBAAsB;AAc1B,OAAO,MAAMC,yBAAyB,GAAGA,CAAA,KAAM;EAC3C,OAAO,OAAO;IAAEC,IAAI;IAAEC;EAAwD,CAAC,KAAK;IAChF,MAAM;MAAEC,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C,MAAM,EAAE,IAAI;UAAEC,YAAY,EAAE,KAAK;UAAEC,UAAU,EAAE;QAAE,CAAC;QAC1DC,KAAK,EAAE;MACX,CAAC;IAET,CAAC,CAAC,OAAOA,KAAK,EAAE;MACZ,OAAO;QACHL,IAAI,EAAE,EAAE;QACRC,IAAI,EAAE;UAAEC,MAAM,EAAE,IAAI;UAAEC,YAAY,EAAE,KAAK;UAAEC,UAAU,EAAE;QAAE,CAAC;QAC1DC,KAAK,EAAE;UACHC,OAAO,EAAEnC,eAAe,CAACkC,KAAK,EAAE,wBAAwB,CAAC;UACzDE,IAAI,EAAE;QACV;MACJ,CAAC;IACL;EACJ,CAAC;AACL,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["getModel","getErrorMessage","buildFieldsSelection","transformSortToArray","transformWhereToNested","createListEntriesResolver","args","context","modelId","where","sort","limit","after","search","fields","preview","model","apiType","executeSchema","cms","getExecutableSchema","fieldsSelection","transformedSort","transformedWhere","query","pluralApiName","singularApiName","result","variables","errors","length","data","meta","cursor","hasMoreItems","totalCount","error","message","map","e","join","code","operationName"],"sources":["listEntriesResolver.ts"],"sourcesContent":["import type { CmsContext } from \"~/types/index.js\";\nimport type { ApiEndpoint } from \"~/types/index.js\";\nimport type { ExecutionResult } from \"graphql\";\nimport {\n getModel,\n getErrorMessage,\n buildFieldsSelection,\n transformSortToArray,\n transformWhereToNested\n} from \"./helpers.js\";\n\nexport interface ListEntriesArgs {\n modelId: string;\n where?: Record<string, unknown>;\n sort?: Record<string, unknown> | string[];\n limit?: number;\n after?: string;\n search?: string;\n fields: string[];\n preview?: boolean;\n}\n\nexport const createListEntriesResolver = () => {\n return async ({ args, context }: { args: ListEntriesArgs; context: CmsContext }) => {\n const { modelId, where, sort, limit, after, search, fields, preview = false } = args;\n\n try {\n const model = await getModel(context, modelId);\n\n // Determine which API to use based on the preview flag.\n // preview=true -> preview API, preview=false -> read API\n const apiType: ApiEndpoint = preview ? \"preview\" : \"read\";\n const executeSchema = await context.cms.getExecutableSchema(apiType);\n\n const fieldsSelection = buildFieldsSelection(fields);\n\n // Transform sort to array format expected by the underlying GraphQL schema.\n // Handles both object format {createdOn: \"desc\"} and array format [\"createdOn_DESC\"].\n const transformedSort = transformSortToArray(sort);\n\n // Transform dot-notation where keys (e.g. \"values.name\") into nested objects\n // (e.g. { values: { name: ... } }) so they match the typed ListWhereInput.\n const transformedWhere = transformWhereToNested(where);\n\n const query = /* GraphQL */ `\n query List${model.pluralApiName}(\n $where: ${model.singularApiName}ListWhereInput\n $sort: [${model.singularApiName}ListSorter!]\n $limit: Int\n $after: String\n $search: String\n ) {\n list${model.pluralApiName}(\n where: $where\n sort: $sort\n limit: $limit\n after: $after\n search: $search\n ) {\n data {\n ${fieldsSelection}\n }\n meta {\n cursor\n hasMoreItems\n totalCount\n }\n error {\n message\n code\n data\n }\n }\n }\n `;\n\n const result = (await executeSchema({\n query,\n variables: { where: transformedWhere, sort: transformedSort, limit, after, search }\n })) as ExecutionResult;\n\n if (result.errors && result.errors.length > 0) {\n return {\n data: [],\n meta: { cursor: null, hasMoreItems: false, totalCount: 0 },\n error: {\n message: result.errors.map(e => e.message).join(\"; \"),\n code: \"LIST_ENTRIES_ERROR\"\n }\n };\n }\n\n const operationName = `list${model.pluralApiName}`;\n return (\n result.data?.[operationName] || {\n data: [],\n meta: { cursor: null, hasMoreItems: false, totalCount: 0 },\n error: null\n }\n );\n } catch (error) {\n return {\n data: [],\n meta: { cursor: null, hasMoreItems: false, totalCount: 0 },\n error: {\n message: getErrorMessage(error, \"Failed to list entries\"),\n code: \"LIST_ENTRIES_ERROR\"\n }\n };\n }\n };\n};\n"],"mappings":"AAGA,SACIA,QAAQ,EACRC,eAAe,EACfC,oBAAoB,EACpBC,oBAAoB,EACpBC,sBAAsB;AAc1B,OAAO,MAAMC,yBAAyB,GAAGA,CAAA,KAAM;EAC3C,OAAO,OAAO;IAAEC,IAAI;IAAEC;EAAwD,CAAC,KAAK;IAChF,MAAM;MAAEC,OAAO;MA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EC,YAAY,EAAE,KAAK;YAAEC,UAAU,EAAE;UAAE,CAAC;UAC1DC,KAAK,EAAE;YACHC,OAAO,EAAEV,MAAM,CAACE,MAAM,CAACS,GAAG,CAACC,CAAC,IAAIA,CAAC,CAACF,OAAO,CAAC,CAACG,IAAI,CAAC,IAAI,CAAC;YACrDC,IAAI,EAAE;UACV;QACJ,CAAC;MACL;MAEA,MAAMC,aAAa,GAAG,OAAO1B,KAAK,CAACS,aAAa,EAAE;MAClD,OACIE,MAAM,CAACI,IAAI,GAAGW,aAAa,CAAC,IAAI;QAC5BX,IAAI,EAAE,EAAE;QACRC,IAAI,EAAE;UAAEC,MAAM,EAAE,IAAI;UAAEC,YAAY,EAAE,KAAK;UAAEC,UAAU,EAAE;QAAE,CAAC;QAC1DC,KAAK,EAAE;MACX,CAAC;IAET,CAAC,CAAC,OAAOA,KAAK,EAAE;MACZ,OAAO;QACHL,IAAI,EAAE,EAAE;QACRC,IAAI,EAAE;UAAEC,MAAM,EAAE,IAAI;UAAEC,YAAY,EAAE,KAAK;UAAEC,UAAU,EAAE;QAAE,CAAC;QAC1DC,KAAK,EAAE;UACHC,OAAO,EAAEpC,eAAe,CAACmC,KAAK,EAAE,wBAAwB,CAAC;UACzDK,IAAI,EAAE;QACV;MACJ,CAAC;IACL;EACJ,CAAC;AACL,CAAC","ignoreList":[]}
@@ -36,6 +36,15 @@ export const createPublishEntryRevisionResolver = () => {
36
36
  revisionId
37
37
  }
38
38
  });
39
+ if (result.errors && result.errors.length > 0) {
40
+ return {
41
+ data: null,
42
+ error: {
43
+ message: result.errors.map(e => e.message).join("; "),
44
+ code: "PUBLISH_ENTRY_ERROR"
45
+ }
46
+ };
47
+ }
39
48
  const operationName = `publish${model.singularApiName}`;
40
49
  return result.data?.[operationName] || {
41
50
  data: null,
@@ -1 +1 @@
1
- {"version":3,"names":["getModel","getErrorMessage","buildFieldsSelection","createPublishEntryRevisionResolver","args","context","modelId","revisionId","fields","model","apiType","executeSchema","cms","getExecutableSchema","fieldsSelection","query","singularApiName","result","variables","operationName","data","error","message","code"],"sources":["publishEntryResolver.ts"],"sourcesContent":["import type { CmsContext } from \"~/types/index.js\";\nimport type { ApiEndpoint } from \"~/types/index.js\";\nimport type { ExecutionResult } from \"graphql\";\nimport { getModel, getErrorMessage, buildFieldsSelection } from \"./helpers.js\";\n\nexport interface PublishEntryRevisionArgs {\n modelId: string;\n revisionId: string;\n fields: string[];\n}\n\nexport const createPublishEntryRevisionResolver = () => {\n return async ({ args, context }: { args: PublishEntryRevisionArgs; context: CmsContext }) => {\n const { modelId, revisionId, fields } = args;\n\n try {\n const model = await getModel(context, modelId);\n\n // Use manage API for publishing entries.\n const apiType: ApiEndpoint = \"manage\";\n const executeSchema = await context.cms.getExecutableSchema(apiType);\n\n const fieldsSelection = buildFieldsSelection(fields);\n\n const query = /* GraphQL */ `\n mutation Publish${model.singularApiName}($revisionId: ID!) {\n publish${model.singularApiName}(revision: $revisionId) {\n data {\n ${fieldsSelection}\n }\n error {\n message\n code\n data\n }\n }\n }\n `;\n\n const result = (await executeSchema({\n query,\n variables: { revisionId }\n })) as ExecutionResult;\n\n const operationName = `publish${model.singularApiName}`;\n return result.data?.[operationName] || { data: null, error: null };\n } catch (error) {\n return {\n data: null,\n error: {\n message: getErrorMessage(error, \"Failed to publish entry\"),\n code: \"PUBLISH_ENTRY_ERROR\"\n }\n };\n }\n };\n};\n"],"mappings":"AAGA,SAASA,QAAQ,EAAEC,eAAe,EAAEC,oBAAoB;AAQxD,OAAO,MAAMC,kCAAkC,GAAGA,CAAA,KAAM;EACpD,OAAO,OAAO;IAAEC,IAAI;IAAEC;EAAiE,CAAC,KAAK;IACzF,MAAM;MAAEC,OAAO;MAAEC,UAAU;MAAEC;IAAO,CAAC,GAAGJ,IAAI;IAE5C,IAAI;MACA,MAAMK,KAAK,GAAG,MAAMT,QAAQ,CAACK,OAAO,EAAEC,OAAO,CAAC;;MAE9C;MACA,MAAMI,OAAoB,GAAG,QAAQ;MACrC,MAAMC,aAAa,GAAG,MAAMN,OAAO,CAACO,GAAG,CAACC,mBAAmB,CAACH,OAAO,CAAC;MAEpE,MAAMI,eAAe,GAAGZ,oBAAoB,CAACM,MAAM,CAAC;MAEpD,MAAMO,KAAK,GAAG,aAAc;AACxC,kCAAkCN,KAAK,CAACO,eAAe;AACvD,6BAA6BP,KAAK,CAACO,eAAe;AAClD;AACA,8BAA8BF,eAAe;AAC7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;MAED,MAAMG,MAAM,GAAI,MAAMN,aAAa,CAAC;QAChCI,KAAK;QACLG,SAAS,EAAE;UAAEX;QAAW;MAC5B,CAAC,CAAqB;MAEtB,MAAMY,aAAa,GAAG,UAAUV,KAAK,CAACO,eAAe,EAAE;MACvD,OAAOC,MAAM,CAACG,IAAI,GAAGD,aAAa,CAAC,IAAI;QAAEC,IAAI,EAAE,IAAI;QAAEC,KAAK,EAAE;MAAK,CAAC;IACtE,CAAC,CAAC,OAAOA,KAAK,EAAE;MACZ,OAAO;QACHD,IAAI,EAAE,IAAI;QACVC,KAAK,EAAE;UACHC,OAAO,EAAErB,eAAe,CAACoB,KAAK,EAAE,yBAAyB,CAAC;UAC1DE,IAAI,EAAE;QACV;MACJ,CAAC;IACL;EACJ,CAAC;AACL,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["getModel","getErrorMessage","buildFieldsSelection","createPublishEntryRevisionResolver","args","context","modelId","revisionId","fields","model","apiType","executeSchema","cms","getExecutableSchema","fieldsSelection","query","singularApiName","result","variables","errors","length","data","error","message","map","e","join","code","operationName"],"sources":["publishEntryResolver.ts"],"sourcesContent":["import type { CmsContext } from \"~/types/index.js\";\nimport type { ApiEndpoint } from \"~/types/index.js\";\nimport type { ExecutionResult } from \"graphql\";\nimport { getModel, getErrorMessage, buildFieldsSelection } from \"./helpers.js\";\n\nexport interface PublishEntryRevisionArgs {\n modelId: string;\n revisionId: string;\n fields: string[];\n}\n\nexport const createPublishEntryRevisionResolver = () => {\n return async ({ args, context }: { args: PublishEntryRevisionArgs; context: CmsContext }) => {\n const { modelId, revisionId, fields } = args;\n\n try {\n const model = await getModel(context, modelId);\n\n // Use manage API for publishing entries.\n const apiType: ApiEndpoint = \"manage\";\n const executeSchema = await context.cms.getExecutableSchema(apiType);\n\n const fieldsSelection = buildFieldsSelection(fields);\n\n const query = /* GraphQL */ `\n mutation Publish${model.singularApiName}($revisionId: ID!) {\n publish${model.singularApiName}(revision: $revisionId) {\n data {\n ${fieldsSelection}\n }\n error {\n message\n code\n data\n }\n }\n }\n `;\n\n const result = (await executeSchema({\n query,\n variables: { revisionId }\n })) as ExecutionResult;\n\n if (result.errors && result.errors.length > 0) {\n return {\n data: null,\n error: {\n message: result.errors.map(e => e.message).join(\"; \"),\n code: \"PUBLISH_ENTRY_ERROR\"\n }\n };\n }\n\n const operationName = `publish${model.singularApiName}`;\n return result.data?.[operationName] || { data: null, error: null };\n } catch (error) {\n return {\n data: null,\n error: {\n message: getErrorMessage(error, \"Failed to publish entry\"),\n code: \"PUBLISH_ENTRY_ERROR\"\n }\n };\n }\n };\n};\n"],"mappings":"AAGA,SAASA,QAAQ,EAAEC,eAAe,EAAEC,oBAAoB;AAQxD,OAAO,MAAMC,kCAAkC,GAAGA,CAAA,KAAM;EACpD,OAAO,OAAO;IAAEC,IAAI;IAAEC;EAAiE,CAAC,KAAK;IACzF,MAAM;MAAEC,OAAO;MAAEC,UAAU;MAAEC;IAAO,CAAC,GAAGJ,IAAI;IAE5C,IAAI;MACA,MAAMK,KAAK,GAAG,MAAMT,QAAQ,CAACK,OAAO,EAAEC,OAAO,CAAC;;MAE9C;MACA,MAAMI,OAAoB,GAAG,QAAQ;MACrC,MAAMC,aAAa,GAAG,MAAMN,OAAO,CAACO,GAAG,CAACC,mBAAmB,CAACH,OAAO,CAAC;MAEpE,MAAMI,eAAe,GAAGZ,oBAAoB,CAACM,MAAM,CAAC;MAEpD,MAAMO,KAAK,GAAG,aAAc;AACxC,kCAAkCN,KAAK,CAACO,eAAe;AACvD,6BAA6BP,KAAK,CAACO,eAAe;AAClD;AACA,8BAA8BF,eAAe;AAC7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;MAED,MAAMG,MAAM,GAAI,MAAMN,aAAa,CAAC;QAChCI,KAAK;QACLG,SAAS,EAAE;UAAEX;QAAW;MAC5B,CAAC,CAAqB;MAEtB,IAAIU,MAAM,CAACE,MAAM,IAAIF,MAAM,CAACE,MAAM,CAACC,MAAM,GAAG,CAAC,EAAE;QAC3C,OAAO;UACHC,IAAI,EAAE,IAAI;UACVC,KAAK,EAAE;YACHC,OAAO,EAAEN,MAAM,CAACE,MAAM,CAACK,GAAG,CAACC,CAAC,IAAIA,CAAC,CAACF,OAAO,CAAC,CAACG,IAAI,CAAC,IAAI,CAAC;YACrDC,IAAI,EAAE;UACV;QACJ,CAAC;MACL;MAEA,MAAMC,aAAa,GAAG,UAAUnB,KAAK,CAACO,eAAe,EAAE;MACvD,OAAOC,MAAM,CAACI,IAAI,GAAGO,aAAa,CAAC,IAAI;QAAEP,IAAI,EAAE,IAAI;QAAEC,KAAK,EAAE;MAAK,CAAC;IACtE,CAAC,CAAC,OAAOA,KAAK,EAAE;MACZ,OAAO;QACHD,IAAI,EAAE,IAAI;QACVC,KAAK,EAAE;UACHC,OAAO,EAAEtB,eAAe,CAACqB,KAAK,EAAE,yBAAyB,CAAC;UAC1DK,IAAI,EAAE;QACV;MACJ,CAAC;IACL;EACJ,CAAC;AACL,CAAC","ignoreList":[]}
@@ -36,6 +36,15 @@ export const createUnpublishEntryRevisionResolver = () => {
36
36
  revisionId
37
37
  }
38
38
  });
39
+ if (result.errors && result.errors.length > 0) {
40
+ return {
41
+ data: null,
42
+ error: {
43
+ message: result.errors.map(e => e.message).join("; "),
44
+ code: "UNPUBLISH_ENTRY_ERROR"
45
+ }
46
+ };
47
+ }
39
48
  const operationName = `unpublish${model.singularApiName}`;
40
49
  return result.data?.[operationName] || {
41
50
  data: null,
@@ -1 +1 @@
1
- {"version":3,"names":["getModel","getErrorMessage","buildFieldsSelection","createUnpublishEntryRevisionResolver","args","context","modelId","revisionId","fields","model","apiType","executeSchema","cms","getExecutableSchema","fieldsSelection","query","singularApiName","result","variables","operationName","data","error","message","code"],"sources":["unpublishEntryResolver.ts"],"sourcesContent":["import type { CmsContext } from \"~/types/index.js\";\nimport type { ApiEndpoint } from \"~/types/index.js\";\nimport type { ExecutionResult } from \"graphql\";\nimport { getModel, getErrorMessage, buildFieldsSelection } from \"./helpers.js\";\n\nexport interface UnpublishEntryRevisionArgs {\n modelId: string;\n revisionId: string;\n fields: string[];\n}\n\nexport const createUnpublishEntryRevisionResolver = () => {\n return async ({ args, context }: { args: UnpublishEntryRevisionArgs; context: CmsContext }) => {\n const { modelId, revisionId, fields } = args;\n\n try {\n const model = await getModel(context, modelId);\n\n // Use manage API for unpublishing entries.\n const apiType: ApiEndpoint = \"manage\";\n const executeSchema = await context.cms.getExecutableSchema(apiType);\n\n const fieldsSelection = buildFieldsSelection(fields);\n\n const query = /* GraphQL */ `\n mutation Unpublish${model.singularApiName}($revisionId: ID!) {\n unpublish${model.singularApiName}(revision: $revisionId) {\n data {\n ${fieldsSelection}\n }\n error {\n message\n code\n data\n }\n }\n }\n `;\n\n const result = (await executeSchema({\n query,\n variables: { revisionId }\n })) as ExecutionResult;\n\n const operationName = `unpublish${model.singularApiName}`;\n return result.data?.[operationName] || { data: null, error: null };\n } catch (error) {\n return {\n data: null,\n error: {\n message: getErrorMessage(error, \"Failed to unpublish entry\"),\n code: \"UNPUBLISH_ENTRY_ERROR\"\n }\n };\n }\n };\n};\n"],"mappings":"AAGA,SAASA,QAAQ,EAAEC,eAAe,EAAEC,oBAAoB;AAQxD,OAAO,MAAMC,oCAAoC,GAAGA,CAAA,KAAM;EACtD,OAAO,OAAO;IAAEC,IAAI;IAAEC;EAAmE,CAAC,KAAK;IAC3F,MAAM;MAAEC,OAAO;MAAEC,UAAU;MAAEC;IAAO,CAAC,GAAGJ,IAAI;IAE5C,IAAI;MACA,MAAMK,KAAK,GAAG,MAAMT,QAAQ,CAACK,OAAO,EAAEC,OAAO,CAAC;;MAE9C;MACA,MAAMI,OAAoB,GAAG,QAAQ;MACrC,MAAMC,aAAa,GAAG,MAAMN,OAAO,CAACO,GAAG,CAACC,mBAAmB,CAACH,OAAO,CAAC;MAEpE,MAAMI,eAAe,GAAGZ,oBAAoB,CAACM,MAAM,CAAC;MAEpD,MAAMO,KAAK,GAAG,aAAc;AACxC,oCAAoCN,KAAK,CAACO,eAAe;AACzD,+BAA+BP,KAAK,CAACO,eAAe;AACpD;AACA,8BAA8BF,eAAe;AAC7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;MAED,MAAMG,MAAM,GAAI,MAAMN,aAAa,CAAC;QAChCI,KAAK;QACLG,SAAS,EAAE;UAAEX;QAAW;MAC5B,CAAC,CAAqB;MAEtB,MAAMY,aAAa,GAAG,YAAYV,KAAK,CAACO,eAAe,EAAE;MACzD,OAAOC,MAAM,CAACG,IAAI,GAAGD,aAAa,CAAC,IAAI;QAAEC,IAAI,EAAE,IAAI;QAAEC,KAAK,EAAE;MAAK,CAAC;IACtE,CAAC,CAAC,OAAOA,KAAK,EAAE;MACZ,OAAO;QACHD,IAAI,EAAE,IAAI;QACVC,KAAK,EAAE;UACHC,OAAO,EAAErB,eAAe,CAACoB,KAAK,EAAE,2BAA2B,CAAC;UAC5DE,IAAI,EAAE;QACV;MACJ,CAAC;IACL;EACJ,CAAC;AACL,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["getModel","getErrorMessage","buildFieldsSelection","createUnpublishEntryRevisionResolver","args","context","modelId","revisionId","fields","model","apiType","executeSchema","cms","getExecutableSchema","fieldsSelection","query","singularApiName","result","variables","errors","length","data","error","message","map","e","join","code","operationName"],"sources":["unpublishEntryResolver.ts"],"sourcesContent":["import type { CmsContext } from \"~/types/index.js\";\nimport type { ApiEndpoint } from \"~/types/index.js\";\nimport type { ExecutionResult } from \"graphql\";\nimport { getModel, getErrorMessage, buildFieldsSelection } from \"./helpers.js\";\n\nexport interface UnpublishEntryRevisionArgs {\n modelId: string;\n revisionId: string;\n fields: string[];\n}\n\nexport const createUnpublishEntryRevisionResolver = () => {\n return async ({ args, context }: { args: UnpublishEntryRevisionArgs; context: CmsContext }) => {\n const { modelId, revisionId, fields } = args;\n\n try {\n const model = await getModel(context, modelId);\n\n // Use manage API for unpublishing entries.\n const apiType: ApiEndpoint = \"manage\";\n const executeSchema = await context.cms.getExecutableSchema(apiType);\n\n const fieldsSelection = buildFieldsSelection(fields);\n\n const query = /* GraphQL */ `\n mutation Unpublish${model.singularApiName}($revisionId: ID!) {\n unpublish${model.singularApiName}(revision: $revisionId) {\n data {\n ${fieldsSelection}\n }\n error {\n message\n code\n data\n }\n }\n }\n `;\n\n const result = (await executeSchema({\n query,\n variables: { revisionId }\n })) as ExecutionResult;\n\n if (result.errors && result.errors.length > 0) {\n return {\n data: null,\n error: {\n message: result.errors.map(e => e.message).join(\"; \"),\n code: \"UNPUBLISH_ENTRY_ERROR\"\n }\n };\n }\n\n const operationName = `unpublish${model.singularApiName}`;\n return result.data?.[operationName] || { data: null, error: null };\n } catch (error) {\n return {\n data: null,\n error: {\n message: getErrorMessage(error, \"Failed to unpublish entry\"),\n code: \"UNPUBLISH_ENTRY_ERROR\"\n }\n };\n }\n };\n};\n"],"mappings":"AAGA,SAASA,QAAQ,EAAEC,eAAe,EAAEC,oBAAoB;AAQxD,OAAO,MAAMC,oCAAoC,GAAGA,CAAA,KAAM;EACtD,OAAO,OAAO;IAAEC,IAAI;IAAEC;EAAmE,CAAC,KAAK;IAC3F,MAAM;MAAEC,OAAO;MAAEC,UAAU;MAAEC;IAAO,CAAC,GAAGJ,IAAI;IAE5C,IAAI;MACA,MAAMK,KAAK,GAAG,MAAMT,QAAQ,CAACK,OAAO,EAAEC,OAAO,CAAC;;MAE9C;MACA,MAAMI,OAAoB,GAAG,QAAQ;MACrC,MAAMC,aAAa,GAAG,MAAMN,OAAO,CAACO,GAAG,CAACC,mBAAmB,CAACH,OAAO,CAAC;MAEpE,MAAMI,eAAe,GAAGZ,oBAAoB,CAACM,MAAM,CAAC;MAEpD,MAAMO,KAAK,GAAG,aAAc;AACxC,oCAAoCN,KAAK,CAACO,eAAe;AACzD,+BAA+BP,KAAK,CAACO,eAAe;AACpD;AACA,8BAA8BF,eAAe;AAC7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;MAED,MAAMG,MAAM,GAAI,MAAMN,aAAa,CAAC;QAChCI,KAAK;QACLG,SAAS,EAAE;UAAEX;QAAW;MAC5B,CAAC,CAAqB;MAEtB,IAAIU,MAAM,CAACE,MAAM,IAAIF,MAAM,CAACE,MAAM,CAACC,MAAM,GAAG,CAAC,EAAE;QAC3C,OAAO;UACHC,IAAI,EAAE,IAAI;UACVC,KAAK,EAAE;YACHC,OAAO,EAAEN,MAAM,CAACE,MAAM,CAACK,GAAG,CAACC,CAAC,IAAIA,CAAC,CAACF,OAAO,CAAC,CAACG,IAAI,CAAC,IAAI,CAAC;YACrDC,IAAI,EAAE;UACV;QACJ,CAAC;MACL;MAEA,MAAMC,aAAa,GAAG,YAAYnB,KAAK,CAACO,eAAe,EAAE;MACzD,OAAOC,MAAM,CAACI,IAAI,GAAGO,aAAa,CAAC,IAAI;QAAEP,IAAI,EAAE,IAAI;QAAEC,KAAK,EAAE;MAAK,CAAC;IACtE,CAAC,CAAC,OAAOA,KAAK,EAAE;MACZ,OAAO;QACHD,IAAI,EAAE,IAAI;QACVC,KAAK,EAAE;UACHC,OAAO,EAAEtB,eAAe,CAACqB,KAAK,EAAE,2BAA2B,CAAC;UAC5DK,IAAI,EAAE;QACV;MACJ,CAAC;IACL;EACJ,CAAC;AACL,CAAC","ignoreList":[]}
@@ -38,6 +38,15 @@ export const createUpdateEntryRevisionResolver = () => {
38
38
  data
39
39
  }
40
40
  });
41
+ if (result.errors && result.errors.length > 0) {
42
+ return {
43
+ data: null,
44
+ error: {
45
+ message: result.errors.map(e => e.message).join("; "),
46
+ code: "UPDATE_ENTRY_ERROR"
47
+ }
48
+ };
49
+ }
41
50
  const operationName = `update${model.singularApiName}`;
42
51
  return result.data?.[operationName] || {
43
52
  data: null,