@strapi/core 0.0.0-next.26bde6ef6bf3081acd31bd0e9dac0d9357028b9c → 0.0.0-next.2a9b9b61cfdc484a1736b8c7d460c850ecc64608
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.
Potentially problematic release.
This version of @strapi/core might be problematic. Click here for more details.
- package/dist/Strapi.d.ts.map +1 -1
- package/dist/Strapi.js +2 -0
- package/dist/Strapi.js.map +1 -1
- package/dist/Strapi.mjs +2 -0
- package/dist/Strapi.mjs.map +1 -1
- package/dist/core-api/routes/index.d.ts +4 -22
- package/dist/core-api/routes/index.d.ts.map +1 -1
- package/dist/core-api/routes/index.js +150 -8
- package/dist/core-api/routes/index.js.map +1 -1
- package/dist/core-api/routes/index.mjs +131 -8
- package/dist/core-api/routes/index.mjs.map +1 -1
- package/dist/core-api/routes/validation/attributes.d.ts +244 -0
- package/dist/core-api/routes/validation/attributes.d.ts.map +1 -0
- package/dist/core-api/routes/validation/attributes.js +560 -0
- package/dist/core-api/routes/validation/attributes.js.map +1 -0
- package/dist/core-api/routes/validation/attributes.mjs +521 -0
- package/dist/core-api/routes/validation/attributes.mjs.map +1 -0
- package/dist/core-api/routes/validation/common.d.ts +105 -0
- package/dist/core-api/routes/validation/common.d.ts.map +1 -0
- package/dist/core-api/routes/validation/common.js +116 -0
- package/dist/core-api/routes/validation/common.js.map +1 -0
- package/dist/core-api/routes/validation/common.mjs +95 -0
- package/dist/core-api/routes/validation/common.mjs.map +1 -0
- package/dist/core-api/routes/validation/component.d.ts +34 -0
- package/dist/core-api/routes/validation/component.d.ts.map +1 -0
- package/dist/core-api/routes/validation/component.js +45 -0
- package/dist/core-api/routes/validation/component.js.map +1 -0
- package/dist/core-api/routes/validation/component.mjs +43 -0
- package/dist/core-api/routes/validation/component.mjs.map +1 -0
- package/dist/core-api/routes/validation/constants.d.ts +8 -0
- package/dist/core-api/routes/validation/constants.d.ts.map +1 -0
- package/dist/core-api/routes/validation/constants.js +18 -0
- package/dist/core-api/routes/validation/constants.js.map +1 -0
- package/dist/core-api/routes/validation/constants.mjs +16 -0
- package/dist/core-api/routes/validation/constants.mjs.map +1 -0
- package/dist/core-api/routes/validation/content-type.d.ts +128 -0
- package/dist/core-api/routes/validation/content-type.d.ts.map +1 -0
- package/dist/core-api/routes/validation/content-type.js +201 -0
- package/dist/core-api/routes/validation/content-type.js.map +1 -0
- package/dist/core-api/routes/validation/content-type.mjs +180 -0
- package/dist/core-api/routes/validation/content-type.mjs.map +1 -0
- package/dist/core-api/routes/validation/index.d.ts +5 -0
- package/dist/core-api/routes/validation/index.d.ts.map +1 -0
- package/dist/core-api/routes/validation/mappers.d.ts +105 -0
- package/dist/core-api/routes/validation/mappers.d.ts.map +1 -0
- package/dist/core-api/routes/validation/mappers.js +238 -0
- package/dist/core-api/routes/validation/mappers.js.map +1 -0
- package/dist/core-api/routes/validation/mappers.mjs +214 -0
- package/dist/core-api/routes/validation/mappers.mjs.map +1 -0
- package/dist/core-api/routes/validation/utils.d.ts +47 -0
- package/dist/core-api/routes/validation/utils.d.ts.map +1 -0
- package/dist/core-api/routes/validation/utils.js +112 -0
- package/dist/core-api/routes/validation/utils.js.map +1 -0
- package/dist/core-api/routes/validation/utils.mjs +90 -0
- package/dist/core-api/routes/validation/utils.mjs.map +1 -0
- package/dist/domain/content-type/index.d.ts.map +1 -1
- package/dist/domain/content-type/index.js +17 -1
- package/dist/domain/content-type/index.js.map +1 -1
- package/dist/domain/content-type/index.mjs +17 -1
- package/dist/domain/content-type/index.mjs.map +1 -1
- package/dist/domain/module/index.d.ts.map +1 -1
- package/dist/domain/module/index.js +3 -0
- package/dist/domain/module/index.js.map +1 -1
- package/dist/domain/module/index.mjs +3 -0
- package/dist/domain/module/index.mjs.map +1 -1
- package/dist/factories.d.ts +3 -1
- package/dist/factories.d.ts.map +1 -1
- package/dist/factories.js +10 -2
- package/dist/factories.js.map +1 -1
- package/dist/factories.mjs +10 -3
- package/dist/factories.mjs.map +1 -1
- package/dist/middlewares/cors.d.ts +9 -1
- package/dist/middlewares/cors.d.ts.map +1 -1
- package/dist/middlewares/cors.js +39 -17
- package/dist/middlewares/cors.js.map +1 -1
- package/dist/middlewares/cors.mjs +39 -18
- package/dist/middlewares/cors.mjs.map +1 -1
- package/dist/migrations/first-published-at.d.ts +4 -0
- package/dist/migrations/first-published-at.d.ts.map +1 -0
- package/dist/migrations/first-published-at.js +51 -0
- package/dist/migrations/first-published-at.js.map +1 -0
- package/dist/migrations/first-published-at.mjs +49 -0
- package/dist/migrations/first-published-at.mjs.map +1 -0
- package/dist/migrations/index.d.ts.map +1 -1
- package/dist/migrations/index.js +5 -0
- package/dist/migrations/index.js.map +1 -1
- package/dist/migrations/index.mjs +5 -0
- package/dist/migrations/index.mjs.map +1 -1
- package/dist/package.json.js +15 -12
- package/dist/package.json.js.map +1 -1
- package/dist/package.json.mjs +15 -12
- package/dist/package.json.mjs.map +1 -1
- package/dist/services/document-service/entries.d.ts.map +1 -1
- package/dist/services/document-service/entries.js.map +1 -1
- package/dist/services/document-service/entries.mjs.map +1 -1
- package/dist/services/document-service/first-published-at.d.ts +7 -0
- package/dist/services/document-service/first-published-at.d.ts.map +1 -0
- package/dist/services/document-service/first-published-at.js +31 -0
- package/dist/services/document-service/first-published-at.js.map +1 -0
- package/dist/services/document-service/first-published-at.mjs +28 -0
- package/dist/services/document-service/first-published-at.mjs.map +1 -0
- package/dist/services/document-service/internationalization.d.ts +6 -1
- package/dist/services/document-service/internationalization.d.ts.map +1 -1
- package/dist/services/document-service/internationalization.js +32 -0
- package/dist/services/document-service/internationalization.js.map +1 -1
- package/dist/services/document-service/internationalization.mjs +32 -1
- package/dist/services/document-service/internationalization.mjs.map +1 -1
- package/dist/services/document-service/repository.d.ts.map +1 -1
- package/dist/services/document-service/repository.js +12 -8
- package/dist/services/document-service/repository.js.map +1 -1
- package/dist/services/document-service/repository.mjs +13 -9
- package/dist/services/document-service/repository.mjs.map +1 -1
- package/dist/services/entity-validator/index.d.ts.map +1 -1
- package/dist/services/entity-validator/index.js +9 -0
- package/dist/services/entity-validator/index.js.map +1 -1
- package/dist/services/entity-validator/index.mjs +9 -0
- package/dist/services/entity-validator/index.mjs.map +1 -1
- package/dist/services/entity-validator/validators.d.ts +1 -0
- package/dist/services/entity-validator/validators.d.ts.map +1 -1
- package/dist/services/entity-validator/validators.js.map +1 -1
- package/dist/services/entity-validator/validators.mjs.map +1 -1
- package/dist/services/metrics/index.d.ts +1 -1
- package/dist/services/metrics/index.d.ts.map +1 -1
- package/dist/services/metrics/index.js +9 -8
- package/dist/services/metrics/index.js.map +1 -1
- package/dist/services/metrics/index.mjs +9 -8
- package/dist/services/metrics/index.mjs.map +1 -1
- package/dist/services/metrics/sender.d.ts.map +1 -1
- package/dist/services/metrics/sender.js +2 -2
- package/dist/services/metrics/sender.js.map +1 -1
- package/dist/services/metrics/sender.mjs +2 -2
- package/dist/services/metrics/sender.mjs.map +1 -1
- package/dist/services/server/register-routes.js +22 -2
- package/dist/services/server/register-routes.js.map +1 -1
- package/dist/services/server/register-routes.mjs +22 -2
- package/dist/services/server/register-routes.mjs.map +1 -1
- package/dist/services/server/routing.d.ts +10 -0
- package/dist/services/server/routing.d.ts.map +1 -1
- package/dist/services/server/routing.js +7 -1
- package/dist/services/server/routing.js.map +1 -1
- package/dist/services/server/routing.mjs +7 -1
- package/dist/services/server/routing.mjs.map +1 -1
- package/dist/services/utils/conditional-fields.d.ts +3 -0
- package/dist/services/utils/conditional-fields.d.ts.map +1 -0
- package/dist/services/utils/conditional-fields.js +22 -0
- package/dist/services/utils/conditional-fields.js.map +1 -0
- package/dist/services/utils/conditional-fields.mjs +20 -0
- package/dist/services/utils/conditional-fields.mjs.map +1 -0
- package/dist/utils/transform-content-types-to-models.d.ts +196 -0
- package/dist/utils/transform-content-types-to-models.d.ts.map +1 -1
- package/package.json +15 -12
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../../src/migrations/index.ts"],"sourcesContent":["import * as draftPublishMigrations from './draft-publish';\nimport * as i18nMigrations from './i18n';\nimport type { Input } from './draft-publish';\n\nconst enable = async ({ oldContentTypes, contentTypes }: Input) => {\n await i18nMigrations.enable({ oldContentTypes, contentTypes });\n await draftPublishMigrations.enable({ oldContentTypes, contentTypes });\n};\n\nconst disable = async ({ oldContentTypes, contentTypes }: Input) => {\n await i18nMigrations.disable({ oldContentTypes, contentTypes });\n await draftPublishMigrations.disable({ oldContentTypes, contentTypes });\n};\n\nexport { enable, disable };\n"],"names":["enable","oldContentTypes","contentTypes","i18nMigrations","draftPublishMigrations","disable"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../src/migrations/index.ts"],"sourcesContent":["import * as draftPublishMigrations from './draft-publish';\nimport * as firstPublishedAt from './first-published-at';\nimport * as i18nMigrations from './i18n';\nimport type { Input } from './draft-publish';\n\nconst enable = async ({ oldContentTypes, contentTypes }: Input) => {\n await i18nMigrations.enable({ oldContentTypes, contentTypes });\n await draftPublishMigrations.enable({ oldContentTypes, contentTypes });\n await firstPublishedAt.enable({ oldContentTypes, contentTypes });\n};\n\nconst disable = async ({ oldContentTypes, contentTypes }: Input) => {\n await i18nMigrations.disable({ oldContentTypes, contentTypes });\n await draftPublishMigrations.disable({ oldContentTypes, contentTypes });\n};\n\nexport { enable, disable };\n"],"names":["enable","oldContentTypes","contentTypes","i18nMigrations","draftPublishMigrations","firstPublishedAt","disable"],"mappings":";;;;AAKA,MAAMA,SAAS,OAAO,EAAEC,eAAe,EAAEC,YAAY,EAAS,GAAA;IAC5D,MAAMC,UAAqB,CAAC;AAAEF,QAAAA,eAAAA;AAAiBC,QAAAA;AAAa,KAAA,CAAA;IAC5D,MAAME,qBAA6B,CAAC;AAAEH,QAAAA,eAAAA;AAAiBC,QAAAA;AAAa,KAAA,CAAA;IACpE,MAAMG,sBAAuB,CAAC;AAAEJ,QAAAA,eAAAA;AAAiBC,QAAAA;AAAa,KAAA,CAAA;AAChE;AAEA,MAAMI,UAAU,OAAO,EAAEL,eAAe,EAAEC,YAAY,EAAS,GAAA;IAC7D,MAAMC,WAAsB,CAAC;AAAEF,QAAAA,eAAAA;AAAiBC,QAAAA;AAAa,KAAA,CAAA;IAC7D,MAAME,sBAA8B,CAAC;AAAEH,QAAAA,eAAAA;AAAiBC,QAAAA;AAAa,KAAA,CAAA;AACvE;;;;"}
|
package/dist/package.json.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var name = "@strapi/core";
|
|
6
|
-
var version = "0.0.0-next.
|
|
6
|
+
var version = "0.0.0-next.2a9b9b61cfdc484a1736b8c7d460c850ecc64608";
|
|
7
7
|
var description = "Core of Strapi";
|
|
8
8
|
var homepage = "https://strapi.io";
|
|
9
9
|
var bugs = {
|
|
@@ -59,14 +59,14 @@ var dependencies = {
|
|
|
59
59
|
"@koa/cors": "5.0.0",
|
|
60
60
|
"@koa/router": "12.0.2",
|
|
61
61
|
"@paralleldrive/cuid2": "2.2.2",
|
|
62
|
-
"@strapi/admin": "0.0.0-next.
|
|
63
|
-
"@strapi/database": "0.0.0-next.
|
|
64
|
-
"@strapi/generators": "0.0.0-next.
|
|
65
|
-
"@strapi/logger": "0.0.0-next.
|
|
66
|
-
"@strapi/permissions": "0.0.0-next.
|
|
67
|
-
"@strapi/types": "0.0.0-next.
|
|
68
|
-
"@strapi/typescript-utils": "0.0.0-next.
|
|
69
|
-
"@strapi/utils": "0.0.0-next.
|
|
62
|
+
"@strapi/admin": "0.0.0-next.2a9b9b61cfdc484a1736b8c7d460c850ecc64608",
|
|
63
|
+
"@strapi/database": "0.0.0-next.2a9b9b61cfdc484a1736b8c7d460c850ecc64608",
|
|
64
|
+
"@strapi/generators": "0.0.0-next.2a9b9b61cfdc484a1736b8c7d460c850ecc64608",
|
|
65
|
+
"@strapi/logger": "0.0.0-next.2a9b9b61cfdc484a1736b8c7d460c850ecc64608",
|
|
66
|
+
"@strapi/permissions": "0.0.0-next.2a9b9b61cfdc484a1736b8c7d460c850ecc64608",
|
|
67
|
+
"@strapi/types": "0.0.0-next.2a9b9b61cfdc484a1736b8c7d460c850ecc64608",
|
|
68
|
+
"@strapi/typescript-utils": "0.0.0-next.2a9b9b61cfdc484a1736b8c7d460c850ecc64608",
|
|
69
|
+
"@strapi/utils": "0.0.0-next.2a9b9b61cfdc484a1736b8c7d460c850ecc64608",
|
|
70
70
|
bcryptjs: "2.4.3",
|
|
71
71
|
boxen: "5.1.2",
|
|
72
72
|
chalk: "4.1.2",
|
|
@@ -85,6 +85,7 @@ var dependencies = {
|
|
|
85
85
|
"http-errors": "2.0.0",
|
|
86
86
|
inquirer: "8.2.5",
|
|
87
87
|
"is-docker": "2.2.1",
|
|
88
|
+
"json-logic-js": "2.0.5",
|
|
88
89
|
koa: "2.16.1",
|
|
89
90
|
"koa-body": "6.0.1",
|
|
90
91
|
"koa-compose": "4.1.0",
|
|
@@ -107,7 +108,8 @@ var dependencies = {
|
|
|
107
108
|
statuses: "2.0.1",
|
|
108
109
|
typescript: "5.4.4",
|
|
109
110
|
undici: "6.21.2",
|
|
110
|
-
yup: "0.32.9"
|
|
111
|
+
yup: "0.32.9",
|
|
112
|
+
zod: "3.25.67"
|
|
111
113
|
};
|
|
112
114
|
var devDependencies = {
|
|
113
115
|
"@strapi/ts-zen": "^0.2.0",
|
|
@@ -119,6 +121,7 @@ var devDependencies = {
|
|
|
119
121
|
"@types/global-agent": "2.1.3",
|
|
120
122
|
"@types/http-errors": "2.0.4",
|
|
121
123
|
"@types/jest": "29.5.2",
|
|
124
|
+
"@types/json-logic-js": "2.0.8",
|
|
122
125
|
"@types/koa": "2.13.4",
|
|
123
126
|
"@types/koa-compress": "4.0.3",
|
|
124
127
|
"@types/koa-session": "6.4.1",
|
|
@@ -129,9 +132,9 @@ var devDependencies = {
|
|
|
129
132
|
"@types/node": "18.19.24",
|
|
130
133
|
"@types/node-schedule": "2.1.7",
|
|
131
134
|
"@types/statuses": "2.0.1",
|
|
132
|
-
"eslint-config-custom": "0.0.0-next.
|
|
135
|
+
"eslint-config-custom": "0.0.0-next.2a9b9b61cfdc484a1736b8c7d460c850ecc64608",
|
|
133
136
|
supertest: "6.3.3",
|
|
134
|
-
tsconfig: "0.0.0-next.
|
|
137
|
+
tsconfig: "0.0.0-next.2a9b9b61cfdc484a1736b8c7d460c850ecc64608"
|
|
135
138
|
};
|
|
136
139
|
var engines = {
|
|
137
140
|
node: ">=18.0.0 <=22.x.x",
|
package/dist/package.json.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"package.json.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"package.json.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/package.json.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
var name = "@strapi/core";
|
|
2
|
-
var version = "0.0.0-next.
|
|
2
|
+
var version = "0.0.0-next.2a9b9b61cfdc484a1736b8c7d460c850ecc64608";
|
|
3
3
|
var description = "Core of Strapi";
|
|
4
4
|
var homepage = "https://strapi.io";
|
|
5
5
|
var bugs = {
|
|
@@ -55,14 +55,14 @@ var dependencies = {
|
|
|
55
55
|
"@koa/cors": "5.0.0",
|
|
56
56
|
"@koa/router": "12.0.2",
|
|
57
57
|
"@paralleldrive/cuid2": "2.2.2",
|
|
58
|
-
"@strapi/admin": "0.0.0-next.
|
|
59
|
-
"@strapi/database": "0.0.0-next.
|
|
60
|
-
"@strapi/generators": "0.0.0-next.
|
|
61
|
-
"@strapi/logger": "0.0.0-next.
|
|
62
|
-
"@strapi/permissions": "0.0.0-next.
|
|
63
|
-
"@strapi/types": "0.0.0-next.
|
|
64
|
-
"@strapi/typescript-utils": "0.0.0-next.
|
|
65
|
-
"@strapi/utils": "0.0.0-next.
|
|
58
|
+
"@strapi/admin": "0.0.0-next.2a9b9b61cfdc484a1736b8c7d460c850ecc64608",
|
|
59
|
+
"@strapi/database": "0.0.0-next.2a9b9b61cfdc484a1736b8c7d460c850ecc64608",
|
|
60
|
+
"@strapi/generators": "0.0.0-next.2a9b9b61cfdc484a1736b8c7d460c850ecc64608",
|
|
61
|
+
"@strapi/logger": "0.0.0-next.2a9b9b61cfdc484a1736b8c7d460c850ecc64608",
|
|
62
|
+
"@strapi/permissions": "0.0.0-next.2a9b9b61cfdc484a1736b8c7d460c850ecc64608",
|
|
63
|
+
"@strapi/types": "0.0.0-next.2a9b9b61cfdc484a1736b8c7d460c850ecc64608",
|
|
64
|
+
"@strapi/typescript-utils": "0.0.0-next.2a9b9b61cfdc484a1736b8c7d460c850ecc64608",
|
|
65
|
+
"@strapi/utils": "0.0.0-next.2a9b9b61cfdc484a1736b8c7d460c850ecc64608",
|
|
66
66
|
bcryptjs: "2.4.3",
|
|
67
67
|
boxen: "5.1.2",
|
|
68
68
|
chalk: "4.1.2",
|
|
@@ -81,6 +81,7 @@ var dependencies = {
|
|
|
81
81
|
"http-errors": "2.0.0",
|
|
82
82
|
inquirer: "8.2.5",
|
|
83
83
|
"is-docker": "2.2.1",
|
|
84
|
+
"json-logic-js": "2.0.5",
|
|
84
85
|
koa: "2.16.1",
|
|
85
86
|
"koa-body": "6.0.1",
|
|
86
87
|
"koa-compose": "4.1.0",
|
|
@@ -103,7 +104,8 @@ var dependencies = {
|
|
|
103
104
|
statuses: "2.0.1",
|
|
104
105
|
typescript: "5.4.4",
|
|
105
106
|
undici: "6.21.2",
|
|
106
|
-
yup: "0.32.9"
|
|
107
|
+
yup: "0.32.9",
|
|
108
|
+
zod: "3.25.67"
|
|
107
109
|
};
|
|
108
110
|
var devDependencies = {
|
|
109
111
|
"@strapi/ts-zen": "^0.2.0",
|
|
@@ -115,6 +117,7 @@ var devDependencies = {
|
|
|
115
117
|
"@types/global-agent": "2.1.3",
|
|
116
118
|
"@types/http-errors": "2.0.4",
|
|
117
119
|
"@types/jest": "29.5.2",
|
|
120
|
+
"@types/json-logic-js": "2.0.8",
|
|
118
121
|
"@types/koa": "2.13.4",
|
|
119
122
|
"@types/koa-compress": "4.0.3",
|
|
120
123
|
"@types/koa-session": "6.4.1",
|
|
@@ -125,9 +128,9 @@ var devDependencies = {
|
|
|
125
128
|
"@types/node": "18.19.24",
|
|
126
129
|
"@types/node-schedule": "2.1.7",
|
|
127
130
|
"@types/statuses": "2.0.1",
|
|
128
|
-
"eslint-config-custom": "0.0.0-next.
|
|
131
|
+
"eslint-config-custom": "0.0.0-next.2a9b9b61cfdc484a1736b8c7d460c850ecc64608",
|
|
129
132
|
supertest: "6.3.3",
|
|
130
|
-
tsconfig: "0.0.0-next.
|
|
133
|
+
tsconfig: "0.0.0-next.2a9b9b61cfdc484a1736b8c7d460c850ecc64608"
|
|
131
134
|
};
|
|
132
135
|
var engines = {
|
|
133
136
|
node: ">=18.0.0 <=22.x.x",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"package.json.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"package.json.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entries.d.ts","sourceRoot":"","sources":["../../../src/services/document-service/entries.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAYlD,QAAA,MAAM,oBAAoB,QACnB,IAAI,WAAW,mBACH,QAAQ,eAAe,CAAC,eAAe;;
|
|
1
|
+
{"version":3,"file":"entries.d.ts","sourceRoot":"","sources":["../../../src/services/document-service/entries.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAYlD,QAAA,MAAM,oBAAoB,QACnB,IAAI,WAAW,mBACH,QAAQ,eAAe,CAAC,eAAe;;iBA2EzB,MAAM;4BAUK,GAAG;qBA4BV,GAAG;0BAaE,GAAG;CAoB5C,CAAC;AAEF,OAAO,EAAE,oBAAoB,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entries.js","sources":["../../../src/services/document-service/entries.ts"],"sourcesContent":["import type { UID, Modules } from '@strapi/types';\nimport { async, errors } from '@strapi/utils';\nimport { assoc, omit } from 'lodash/fp';\n\nimport * as components from './components';\n\nimport { transformParamsDocumentId } from './transform/id-transform';\nimport { transformParamsToQuery } from './transform/query';\nimport { pickSelectionParams } from './params';\nimport { applyTransforms } from './attributes';\nimport { transformData } from './transform/data';\n\nconst createEntriesService = (\n uid: UID.ContentType,\n entityValidator: Modules.EntityValidator.EntityValidator\n) => {\n const contentType = strapi.contentType(uid);\n\n async function createEntry(params = {} as any) {\n const { data, ...restParams } = await transformParamsDocumentId(uid, params);\n\n const query = transformParamsToQuery(uid, pickSelectionParams(restParams) as any); // select / populate\n\n // Validation\n if (!data) {\n throw new Error('Create requires data attribute');\n }\n\n // Check for uniqueness based on documentId and locale (if localized)\n if (data.documentId) {\n const i18nService = strapi.plugin('i18n')?.service('content-types');\n const isLocalized = i18nService?.isLocalizedContentType(contentType) ?? false;\n const hasDraftAndPublish = contentType.options?.draftAndPublish === true;\n\n const whereClause: Record<string, unknown> = { documentId: data.documentId };\n\n if (isLocalized) {\n whereClause.locale = data.locale;\n }\n\n let publishedStateDescription = '';\n\n if (hasDraftAndPublish) {\n if (data.publishedAt) {\n // Current entry is published, check for existing published entry\n whereClause.publishedAt = { $notNull: true };\n publishedStateDescription = 'published';\n } else {\n // Current entry is a draft, check for existing draft entry\n whereClause.publishedAt = { $null: true };\n publishedStateDescription = 'draft';\n }\n }\n\n const existingEntry = await strapi.db.query(uid).findOne({\n select: ['id'],\n where: whereClause,\n });\n\n if (existingEntry) {\n let errorMsg = `A ${publishedStateDescription} entry with documentId \"${data.documentId}\"`;\n if (isLocalized && data.locale) {\n errorMsg += ` and locale \"${data.locale}\"`;\n }\n errorMsg += ` already exists for UID \"${uid}\". This combination must be unique.`;\n throw new errors.ApplicationError(errorMsg);\n }\n }\n\n const validData = await entityValidator.validateEntityCreation(contentType, data, {\n // Note: publishedAt value will always be set when DP is disabled\n isDraft: !params?.data?.publishedAt,\n locale: params?.locale,\n });\n\n // Component handling\n const componentData = await components.createComponents(uid, validData);\n const dataWithComponents = components.assignComponentData(\n contentType,\n componentData,\n validData\n );\n\n const entryData = applyTransforms(contentType, dataWithComponents);\n\n const doc = await strapi.db.query(uid).create({ ...query, data: entryData });\n\n return doc;\n }\n\n async function deleteEntry(id: number) {\n const componentsToDelete = await components.getComponents(uid, { id });\n\n const deletedEntry = await strapi.db.query(uid).delete({ where: { id } });\n\n await components.deleteComponents(uid, componentsToDelete as any, { loadComponents: false });\n\n return deletedEntry;\n }\n\n async function updateEntry(entryToUpdate: any, params = {} as any) {\n const { data, ...restParams } = await transformParamsDocumentId(uid, params);\n const query = transformParamsToQuery(uid, pickSelectionParams(restParams) as any); // select / populate\n\n const validData = await entityValidator.validateEntityUpdate(\n contentType,\n data,\n {\n isDraft: !params?.data?.publishedAt, // Always update the draft version\n locale: params?.locale,\n },\n entryToUpdate\n );\n // Component handling\n const componentData = await components.updateComponents(uid, entryToUpdate, validData as any);\n const dataWithComponents = components.assignComponentData(\n contentType,\n componentData,\n validData\n );\n\n const entryData = applyTransforms(contentType, dataWithComponents);\n\n return strapi.db\n .query(uid)\n .update({ ...query, where: { id: entryToUpdate.id }, data: entryData });\n }\n\n async function publishEntry(entry: any, params = {} as any) {\n return async.pipe(\n omit('id'),\n assoc('publishedAt', new Date()),\n (draft) => {\n const opts = { uid, locale: draft.locale, status: 'published', allowMissingId: true };\n return transformData(draft, opts);\n },\n // Create the published entry\n (draft) => createEntry({ ...params, data: draft, locale: draft.locale, status: 'published' })\n )(entry);\n }\n\n async function discardDraftEntry(entry: any, params = {} as any) {\n return async.pipe(\n omit('id'),\n assoc('publishedAt', null),\n (entry) => {\n const opts = { uid, locale: entry.locale, status: 'draft', allowMissingId: true };\n return transformData(entry, opts);\n },\n // Create the draft entry\n (data) => createEntry({ ...params, locale: data.locale, data, status: 'draft' })\n )(entry);\n }\n\n return {\n create: createEntry,\n delete: deleteEntry,\n update: updateEntry,\n publish: publishEntry,\n discardDraft: discardDraftEntry,\n };\n};\n\nexport { createEntriesService };\n"],"names":["createEntriesService","uid","entityValidator","contentType","strapi","createEntry","params","data","restParams","transformParamsDocumentId","query","transformParamsToQuery","pickSelectionParams","Error","documentId","i18nService","plugin","service","isLocalized","isLocalizedContentType","hasDraftAndPublish","options","draftAndPublish","whereClause","locale","publishedStateDescription","publishedAt","$notNull","$null","existingEntry","db","findOne","select","where","errorMsg","errors","ApplicationError","validData","validateEntityCreation","isDraft","componentData","components","dataWithComponents","entryData","applyTransforms","doc","create","deleteEntry","id","componentsToDelete","deletedEntry","delete","loadComponents","updateEntry","entryToUpdate","validateEntityUpdate","update","publishEntry","entry","async","pipe","omit","assoc","Date","draft","opts","status","allowMissingId","transformData","discardDraftEntry","publish","discardDraft"],"mappings":";;;;;;;;;;;AAYMA,MAAAA,oBAAAA,GAAuB,CAC3BC,GACAC,EAAAA,eAAAA,GAAAA;IAEA,MAAMC,WAAAA,GAAcC,MAAOD,CAAAA,WAAW,CAACF,GAAAA,CAAAA;IAEvC,eAAeI,WAAAA,CAAYC,QAAS,GAA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CAAC1D,OAASF,WAAY,CAAA;AAAE,gBAAA,GAAGC,MAAM;AAAEkB,gBAAAA,MAAAA,EAAQjB,KAAKiB,MAAM;AAAEjB,gBAAAA,IAAAA;gBAAM2D,MAAQ,EAAA;aACtER,CAAAA,CAAAA,CAAAA,KAAAA,CAAAA;AACJ;IAEA,OAAO;QACLZ,MAAQzC,EAAAA,WAAAA;QACR8C,MAAQJ,EAAAA,WAAAA;QACRS,MAAQH,EAAAA,WAAAA;QACRiB,OAASb,EAAAA,YAAAA;QACTc,YAAcF,EAAAA;AAChB,KAAA;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"entries.js","sources":["../../../src/services/document-service/entries.ts"],"sourcesContent":["import type { UID, Modules } from '@strapi/types';\nimport { async, errors } from '@strapi/utils';\nimport { assoc, omit } from 'lodash/fp';\n\nimport * as components from './components';\n\nimport { transformParamsDocumentId } from './transform/id-transform';\nimport { transformParamsToQuery } from './transform/query';\nimport { pickSelectionParams } from './params';\nimport { applyTransforms } from './attributes';\nimport { transformData } from './transform/data';\n\nconst createEntriesService = (\n uid: UID.ContentType,\n entityValidator: Modules.EntityValidator.EntityValidator\n) => {\n const contentType = strapi.contentType(uid);\n\n async function createEntry(params = {} as any) {\n const { data, ...restParams } = await transformParamsDocumentId(uid, params);\n const query = transformParamsToQuery(uid, pickSelectionParams(restParams) as any); // select / populate\n\n // Validation\n if (!data) {\n throw new Error('Create requires data attribute');\n }\n\n // Check for uniqueness based on documentId and locale (if localized)\n if (data.documentId) {\n const i18nService = strapi.plugin('i18n')?.service('content-types');\n const isLocalized = i18nService?.isLocalizedContentType(contentType) ?? false;\n const hasDraftAndPublish = contentType.options?.draftAndPublish === true;\n\n const whereClause: Record<string, unknown> = { documentId: data.documentId };\n\n if (isLocalized) {\n whereClause.locale = data.locale;\n }\n\n let publishedStateDescription = '';\n\n if (hasDraftAndPublish) {\n if (data.publishedAt) {\n // Current entry is published, check for existing published entry\n whereClause.publishedAt = { $notNull: true };\n publishedStateDescription = 'published';\n } else {\n // Current entry is a draft, check for existing draft entry\n whereClause.publishedAt = { $null: true };\n publishedStateDescription = 'draft';\n }\n }\n\n const existingEntry = await strapi.db.query(uid).findOne({\n select: ['id'],\n where: whereClause,\n });\n\n if (existingEntry) {\n let errorMsg = `A ${publishedStateDescription} entry with documentId \"${data.documentId}\"`;\n if (isLocalized && data.locale) {\n errorMsg += ` and locale \"${data.locale}\"`;\n }\n errorMsg += ` already exists for UID \"${uid}\". This combination must be unique.`;\n throw new errors.ApplicationError(errorMsg);\n }\n }\n\n const validData = await entityValidator.validateEntityCreation(contentType, data, {\n // Note: publishedAt value will always be set when DP is disabled\n isDraft: !params?.data?.publishedAt,\n locale: params?.locale,\n });\n\n // Component handling\n const componentData = await components.createComponents(uid, validData);\n const dataWithComponents = components.assignComponentData(\n contentType,\n componentData,\n validData\n );\n\n const entryData = applyTransforms(contentType, dataWithComponents);\n\n const doc = await strapi.db.query(uid).create({ ...query, data: entryData });\n\n return doc;\n }\n\n async function deleteEntry(id: number) {\n const componentsToDelete = await components.getComponents(uid, { id });\n\n const deletedEntry = await strapi.db.query(uid).delete({ where: { id } });\n\n await components.deleteComponents(uid, componentsToDelete as any, { loadComponents: false });\n\n return deletedEntry;\n }\n\n async function updateEntry(entryToUpdate: any, params = {} as any) {\n const { data, ...restParams } = await transformParamsDocumentId(uid, params);\n const query = transformParamsToQuery(uid, pickSelectionParams(restParams) as any); // select / populate\n\n const validData = await entityValidator.validateEntityUpdate(\n contentType,\n data,\n {\n isDraft: !params?.data?.publishedAt, // Always update the draft version\n locale: params?.locale,\n },\n entryToUpdate\n );\n // Component handling\n const componentData = await components.updateComponents(uid, entryToUpdate, validData as any);\n const dataWithComponents = components.assignComponentData(\n contentType,\n componentData,\n validData\n );\n\n const entryData = applyTransforms(contentType, dataWithComponents);\n\n return strapi.db\n .query(uid)\n .update({ ...query, where: { id: entryToUpdate.id }, data: entryData });\n }\n\n async function publishEntry(entry: any, params = {} as any) {\n return async.pipe(\n omit('id'),\n assoc('publishedAt', new Date()),\n (draft) => {\n const opts = { uid, locale: draft.locale, status: 'published', allowMissingId: true };\n return transformData(draft, opts);\n },\n // Create the published entry\n (draft) => createEntry({ ...params, data: draft, locale: draft.locale, status: 'published' })\n )(entry);\n }\n\n async function discardDraftEntry(entry: any, params = {} as any) {\n return async.pipe(\n omit('id'),\n assoc('publishedAt', null),\n (entry) => {\n const opts = { uid, locale: entry.locale, status: 'draft', allowMissingId: true };\n return transformData(entry, opts);\n },\n // Create the draft entry\n (data) => createEntry({ ...params, locale: data.locale, data, status: 'draft' })\n )(entry);\n }\n\n return {\n create: createEntry,\n delete: deleteEntry,\n update: updateEntry,\n publish: publishEntry,\n discardDraft: discardDraftEntry,\n };\n};\n\nexport { createEntriesService };\n"],"names":["createEntriesService","uid","entityValidator","contentType","strapi","createEntry","params","data","restParams","transformParamsDocumentId","query","transformParamsToQuery","pickSelectionParams","Error","documentId","i18nService","plugin","service","isLocalized","isLocalizedContentType","hasDraftAndPublish","options","draftAndPublish","whereClause","locale","publishedStateDescription","publishedAt","$notNull","$null","existingEntry","db","findOne","select","where","errorMsg","errors","ApplicationError","validData","validateEntityCreation","isDraft","componentData","components","dataWithComponents","entryData","applyTransforms","doc","create","deleteEntry","id","componentsToDelete","deletedEntry","delete","loadComponents","updateEntry","entryToUpdate","validateEntityUpdate","update","publishEntry","entry","async","pipe","omit","assoc","Date","draft","opts","status","allowMissingId","transformData","discardDraftEntry","publish","discardDraft"],"mappings":";;;;;;;;;;;AAYMA,MAAAA,oBAAAA,GAAuB,CAC3BC,GACAC,EAAAA,eAAAA,GAAAA;IAEA,MAAMC,WAAAA,GAAcC,MAAOD,CAAAA,WAAW,CAACF,GAAAA,CAAAA;IAEvC,eAAeI,WAAAA,CAAYC,QAAS,GAAA,EAAS,EAAA;QAC3C,MAAM,EAAEC,IAAI,EAAE,GAAGC,YAAY,GAAG,MAAMC,sCAA0BR,GAAKK,EAAAA,QAAAA,CAAAA;AACrE,QAAA,MAAMI,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D,MAAQ,EAAA;aACtER,CAAAA,CAAAA,CAAAA,KAAAA,CAAAA;AACJ;IAEA,OAAO;QACLZ,MAAQzC,EAAAA,WAAAA;QACR8C,MAAQJ,EAAAA,WAAAA;QACRS,MAAQH,EAAAA,WAAAA;QACRiB,OAASb,EAAAA,YAAAA;QACTc,YAAcF,EAAAA;AAChB,KAAA;AACF;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entries.mjs","sources":["../../../src/services/document-service/entries.ts"],"sourcesContent":["import type { UID, Modules } from '@strapi/types';\nimport { async, errors } from '@strapi/utils';\nimport { assoc, omit } from 'lodash/fp';\n\nimport * as components from './components';\n\nimport { transformParamsDocumentId } from './transform/id-transform';\nimport { transformParamsToQuery } from './transform/query';\nimport { pickSelectionParams } from './params';\nimport { applyTransforms } from './attributes';\nimport { transformData } from './transform/data';\n\nconst createEntriesService = (\n uid: UID.ContentType,\n entityValidator: Modules.EntityValidator.EntityValidator\n) => {\n const contentType = strapi.contentType(uid);\n\n async function createEntry(params = {} as any) {\n const { data, ...restParams } = await transformParamsDocumentId(uid, params);\n\n const query = transformParamsToQuery(uid, pickSelectionParams(restParams) as any); // select / populate\n\n // Validation\n if (!data) {\n throw new Error('Create requires data attribute');\n }\n\n // Check for uniqueness based on documentId and locale (if localized)\n if (data.documentId) {\n const i18nService = strapi.plugin('i18n')?.service('content-types');\n const isLocalized = i18nService?.isLocalizedContentType(contentType) ?? false;\n const hasDraftAndPublish = contentType.options?.draftAndPublish === true;\n\n const whereClause: Record<string, unknown> = { documentId: data.documentId };\n\n if (isLocalized) {\n whereClause.locale = data.locale;\n }\n\n let publishedStateDescription = '';\n\n if (hasDraftAndPublish) {\n if (data.publishedAt) {\n // Current entry is published, check for existing published entry\n whereClause.publishedAt = { $notNull: true };\n publishedStateDescription = 'published';\n } else {\n // Current entry is a draft, check for existing draft entry\n whereClause.publishedAt = { $null: true };\n publishedStateDescription = 'draft';\n }\n }\n\n const existingEntry = await strapi.db.query(uid).findOne({\n select: ['id'],\n where: whereClause,\n });\n\n if (existingEntry) {\n let errorMsg = `A ${publishedStateDescription} entry with documentId \"${data.documentId}\"`;\n if (isLocalized && data.locale) {\n errorMsg += ` and locale \"${data.locale}\"`;\n }\n errorMsg += ` already exists for UID \"${uid}\". This combination must be unique.`;\n throw new errors.ApplicationError(errorMsg);\n }\n }\n\n const validData = await entityValidator.validateEntityCreation(contentType, data, {\n // Note: publishedAt value will always be set when DP is disabled\n isDraft: !params?.data?.publishedAt,\n locale: params?.locale,\n });\n\n // Component handling\n const componentData = await components.createComponents(uid, validData);\n const dataWithComponents = components.assignComponentData(\n contentType,\n componentData,\n validData\n );\n\n const entryData = applyTransforms(contentType, dataWithComponents);\n\n const doc = await strapi.db.query(uid).create({ ...query, data: entryData });\n\n return doc;\n }\n\n async function deleteEntry(id: number) {\n const componentsToDelete = await components.getComponents(uid, { id });\n\n const deletedEntry = await strapi.db.query(uid).delete({ where: { id } });\n\n await components.deleteComponents(uid, componentsToDelete as any, { loadComponents: false });\n\n return deletedEntry;\n }\n\n async function updateEntry(entryToUpdate: any, params = {} as any) {\n const { data, ...restParams } = await transformParamsDocumentId(uid, params);\n const query = transformParamsToQuery(uid, pickSelectionParams(restParams) as any); // select / populate\n\n const validData = await entityValidator.validateEntityUpdate(\n contentType,\n data,\n {\n isDraft: !params?.data?.publishedAt, // Always update the draft version\n locale: params?.locale,\n },\n entryToUpdate\n );\n // Component handling\n const componentData = await components.updateComponents(uid, entryToUpdate, validData as any);\n const dataWithComponents = components.assignComponentData(\n contentType,\n componentData,\n validData\n );\n\n const entryData = applyTransforms(contentType, dataWithComponents);\n\n return strapi.db\n .query(uid)\n .update({ ...query, where: { id: entryToUpdate.id }, data: entryData });\n }\n\n async function publishEntry(entry: any, params = {} as any) {\n return async.pipe(\n omit('id'),\n assoc('publishedAt', new Date()),\n (draft) => {\n const opts = { uid, locale: draft.locale, status: 'published', allowMissingId: true };\n return transformData(draft, opts);\n },\n // Create the published entry\n (draft) => createEntry({ ...params, data: draft, locale: draft.locale, status: 'published' })\n )(entry);\n }\n\n async function discardDraftEntry(entry: any, params = {} as any) {\n return async.pipe(\n omit('id'),\n assoc('publishedAt', null),\n (entry) => {\n const opts = { uid, locale: entry.locale, status: 'draft', allowMissingId: true };\n return transformData(entry, opts);\n },\n // Create the draft entry\n (data) => createEntry({ ...params, locale: data.locale, data, status: 'draft' })\n )(entry);\n }\n\n return {\n create: createEntry,\n delete: deleteEntry,\n update: updateEntry,\n publish: publishEntry,\n discardDraft: discardDraftEntry,\n };\n};\n\nexport { createEntriesService };\n"],"names":["createEntriesService","uid","entityValidator","contentType","strapi","createEntry","params","data","restParams","transformParamsDocumentId","query","transformParamsToQuery","pickSelectionParams","Error","documentId","i18nService","plugin","service","isLocalized","isLocalizedContentType","hasDraftAndPublish","options","draftAndPublish","whereClause","locale","publishedStateDescription","publishedAt","$notNull","$null","existingEntry","db","findOne","select","where","errorMsg","errors","ApplicationError","validData","validateEntityCreation","isDraft","componentData","components","dataWithComponents","entryData","applyTransforms","doc","create","deleteEntry","id","componentsToDelete","deletedEntry","delete","loadComponents","updateEntry","entryToUpdate","validateEntityUpdate","update","publishEntry","entry","async","pipe","omit","assoc","Date","draft","opts","status","allowMissingId","transformData","discardDraftEntry","publish","discardDraft"],"mappings":";;;;;;;;;AAYMA,MAAAA,oBAAAA,GAAuB,CAC3BC,GACAC,EAAAA,eAAAA,GAAAA;IAEA,MAAMC,WAAAA,GAAcC,MAAOD,CAAAA,WAAW,CAACF,GAAAA,CAAAA;IAEvC,eAAeI,WAAAA,CAAYC,MAAS,GAAA,EAAS,EAAA;QAC3C,MAAM,EAAEC,IAAI,EAAE,GAAGC,YAAY,GAAG,MAAMC,iCAA0BR,GAAKK,EAAAA,MAAAA,CAAAA;AAErE,QAAA,MAAMI,KAAQC,GAAAA,sBAAAA,CAAuBV,GAAKW,EAAAA,mBAAAA,CAAoBJ;;AAG9D,QAAA,IAAI,CAACD,IAAM,EAAA;AACT,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AAQJ,EAAAA,WAAAA;QACRS,MAAQH,EAAAA,WAAAA;QACRiB,OAASb,EAAAA,YAAAA;QACTc,YAAcF,EAAAA;AAChB,KAAA;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"entries.mjs","sources":["../../../src/services/document-service/entries.ts"],"sourcesContent":["import type { UID, Modules } from '@strapi/types';\nimport { async, errors } from '@strapi/utils';\nimport { assoc, omit } from 'lodash/fp';\n\nimport * as components from './components';\n\nimport { transformParamsDocumentId } from './transform/id-transform';\nimport { transformParamsToQuery } from './transform/query';\nimport { pickSelectionParams } from './params';\nimport { applyTransforms } from './attributes';\nimport { transformData } from './transform/data';\n\nconst createEntriesService = (\n uid: UID.ContentType,\n entityValidator: Modules.EntityValidator.EntityValidator\n) => {\n const contentType = strapi.contentType(uid);\n\n async function createEntry(params = {} as any) {\n const { data, ...restParams } = await transformParamsDocumentId(uid, params);\n const query = transformParamsToQuery(uid, pickSelectionParams(restParams) as any); // select / populate\n\n // Validation\n if (!data) {\n throw new Error('Create requires data attribute');\n }\n\n // Check for uniqueness based on documentId and locale (if localized)\n if (data.documentId) {\n const i18nService = strapi.plugin('i18n')?.service('content-types');\n const isLocalized = i18nService?.isLocalizedContentType(contentType) ?? false;\n const hasDraftAndPublish = contentType.options?.draftAndPublish === true;\n\n const whereClause: Record<string, unknown> = { documentId: data.documentId };\n\n if (isLocalized) {\n whereClause.locale = data.locale;\n }\n\n let publishedStateDescription = '';\n\n if (hasDraftAndPublish) {\n if (data.publishedAt) {\n // Current entry is published, check for existing published entry\n whereClause.publishedAt = { $notNull: true };\n publishedStateDescription = 'published';\n } else {\n // Current entry is a draft, check for existing draft entry\n whereClause.publishedAt = { $null: true };\n publishedStateDescription = 'draft';\n }\n }\n\n const existingEntry = await strapi.db.query(uid).findOne({\n select: ['id'],\n where: whereClause,\n });\n\n if (existingEntry) {\n let errorMsg = `A ${publishedStateDescription} entry with documentId \"${data.documentId}\"`;\n if (isLocalized && data.locale) {\n errorMsg += ` and locale \"${data.locale}\"`;\n }\n errorMsg += ` already exists for UID \"${uid}\". This combination must be unique.`;\n throw new errors.ApplicationError(errorMsg);\n }\n }\n\n const validData = await entityValidator.validateEntityCreation(contentType, data, {\n // Note: publishedAt value will always be set when DP is disabled\n isDraft: !params?.data?.publishedAt,\n locale: params?.locale,\n });\n\n // Component handling\n const componentData = await components.createComponents(uid, validData);\n const dataWithComponents = components.assignComponentData(\n contentType,\n componentData,\n validData\n );\n\n const entryData = applyTransforms(contentType, dataWithComponents);\n\n const doc = await strapi.db.query(uid).create({ ...query, data: entryData });\n\n return doc;\n }\n\n async function deleteEntry(id: number) {\n const componentsToDelete = await components.getComponents(uid, { id });\n\n const deletedEntry = await strapi.db.query(uid).delete({ where: { id } });\n\n await components.deleteComponents(uid, componentsToDelete as any, { loadComponents: false });\n\n return deletedEntry;\n }\n\n async function updateEntry(entryToUpdate: any, params = {} as any) {\n const { data, ...restParams } = await transformParamsDocumentId(uid, params);\n const query = transformParamsToQuery(uid, pickSelectionParams(restParams) as any); // select / populate\n\n const validData = await entityValidator.validateEntityUpdate(\n contentType,\n data,\n {\n isDraft: !params?.data?.publishedAt, // Always update the draft version\n locale: params?.locale,\n },\n entryToUpdate\n );\n // Component handling\n const componentData = await components.updateComponents(uid, entryToUpdate, validData as any);\n const dataWithComponents = components.assignComponentData(\n contentType,\n componentData,\n validData\n );\n\n const entryData = applyTransforms(contentType, dataWithComponents);\n\n return strapi.db\n .query(uid)\n .update({ ...query, where: { id: entryToUpdate.id }, data: entryData });\n }\n\n async function publishEntry(entry: any, params = {} as any) {\n return async.pipe(\n omit('id'),\n assoc('publishedAt', new Date()),\n (draft) => {\n const opts = { uid, locale: draft.locale, status: 'published', allowMissingId: true };\n return transformData(draft, opts);\n },\n // Create the published entry\n (draft) => createEntry({ ...params, data: draft, locale: draft.locale, status: 'published' })\n )(entry);\n }\n\n async function discardDraftEntry(entry: any, params = {} as any) {\n return async.pipe(\n omit('id'),\n assoc('publishedAt', null),\n (entry) => {\n const opts = { uid, locale: entry.locale, status: 'draft', allowMissingId: true };\n return transformData(entry, opts);\n },\n // Create the draft entry\n (data) => createEntry({ ...params, locale: data.locale, data, status: 'draft' })\n )(entry);\n }\n\n return {\n create: createEntry,\n delete: deleteEntry,\n update: updateEntry,\n publish: publishEntry,\n discardDraft: discardDraftEntry,\n };\n};\n\nexport { createEntriesService };\n"],"names":["createEntriesService","uid","entityValidator","contentType","strapi","createEntry","params","data","restParams","transformParamsDocumentId","query","transformParamsToQuery","pickSelectionParams","Error","documentId","i18nService","plugin","service","isLocalized","isLocalizedContentType","hasDraftAndPublish","options","draftAndPublish","whereClause","locale","publishedStateDescription","publishedAt","$notNull","$null","existingEntry","db","findOne","select","where","errorMsg","errors","ApplicationError","validData","validateEntityCreation","isDraft","componentData","components","dataWithComponents","entryData","applyTransforms","doc","create","deleteEntry","id","componentsToDelete","deletedEntry","delete","loadComponents","updateEntry","entryToUpdate","validateEntityUpdate","update","publishEntry","entry","async","pipe","omit","assoc","Date","draft","opts","status","allowMissingId","transformData","discardDraftEntry","publish","discardDraft"],"mappings":";;;;;;;;;AAYMA,MAAAA,oBAAAA,GAAuB,CAC3BC,GACAC,EAAAA,eAAAA,GAAAA;IAEA,MAAMC,WAAAA,GAAcC,MAAOD,CAAAA,WAAW,CAACF,GAAAA,CAAAA;IAEvC,eAAeI,WAAAA,CAAYC,MAAS,GAAA,EAAS,EAAA;QAC3C,MAAM,EAAEC,IAAI,EAAE,GAAGC,YAAY,GAAG,MAAMC,iCAA0BR,GAAKK,EAAAA,MAAAA,CAAAA;AACrE,QAAA,MAAMI,KAAQC,GAAAA,sBAAAA,CAAuBV,GAAKW,EAAAA,mBAAAA,CAAoBJ;;AAG9D,QAAA,IAAI,CAACD,IAAM,EAAA;AACT,YAAA,MAAM,IAAIM,KAAM,CAAA,gCAAA,CAAA;AAClB;;QAGA,IAAIN,IAAAA,CAAKO,UAAU,EAAE;AACnB,YAAA,MAAMC,WAAcX,GAAAA,MAAAA,CAAOY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,7 @@
|
|
|
1
|
+
import type { Modules, Schema } from '@strapi/types';
|
|
2
|
+
type EntriesUpdate = (entryToUpdate: any, param?: any) => Promise<any>;
|
|
3
|
+
type ParamsTransform = (params: Modules.Documents.Params.All) => Modules.Documents.Params.All;
|
|
4
|
+
declare const addFirstPublishedAtToDraft: (draft: any, update: EntriesUpdate, contentType: Schema.ContentType) => Promise<any>;
|
|
5
|
+
declare const filterDataFirstPublishedAt: ParamsTransform;
|
|
6
|
+
export { addFirstPublishedAtToDraft, filterDataFirstPublishedAt };
|
|
7
|
+
//# sourceMappingURL=first-published-at.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"first-published-at.d.ts","sourceRoot":"","sources":["../../../src/services/document-service/first-published-at.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAErD,KAAK,aAAa,GAAG,CAAC,aAAa,EAAE,GAAG,EAAE,KAAK,CAAC,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;AACvE,KAAK,eAAe,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG,KAAK,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC;AAE9F,QAAA,MAAM,0BAA0B,UACvB,GAAG,UACF,aAAa,eACR,OAAO,WAAW,iBAehC,CAAC;AAEF,QAAA,MAAM,0BAA0B,EAAE,eAMjC,CAAC;AAEF,OAAO,EAAE,0BAA0B,EAAE,0BAA0B,EAAE,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var strapiUtils = require('@strapi/utils');
|
|
4
|
+
var fp = require('lodash/fp');
|
|
5
|
+
|
|
6
|
+
const addFirstPublishedAtToDraft = async (draft, update, contentType)=>{
|
|
7
|
+
if (!strapiUtils.contentTypes.hasFirstPublishedAtField(contentType)) {
|
|
8
|
+
return draft;
|
|
9
|
+
}
|
|
10
|
+
if (draft.firstPublishedAt) {
|
|
11
|
+
return draft;
|
|
12
|
+
}
|
|
13
|
+
return update(draft, {
|
|
14
|
+
data: {
|
|
15
|
+
firstPublishedAt: Date.now()
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
const filterDataFirstPublishedAt = (params)=>{
|
|
20
|
+
if (params?.data?.firstPublishedAt) {
|
|
21
|
+
return fp.assoc([
|
|
22
|
+
'data',
|
|
23
|
+
'firstPublishedAt'
|
|
24
|
+
], null, params);
|
|
25
|
+
}
|
|
26
|
+
return params;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
exports.addFirstPublishedAtToDraft = addFirstPublishedAtToDraft;
|
|
30
|
+
exports.filterDataFirstPublishedAt = filterDataFirstPublishedAt;
|
|
31
|
+
//# sourceMappingURL=first-published-at.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"first-published-at.js","sources":["../../../src/services/document-service/first-published-at.ts"],"sourcesContent":["import { contentTypes } from '@strapi/utils';\nimport { assoc } from 'lodash/fp';\nimport type { Modules, Schema } from '@strapi/types';\n\ntype EntriesUpdate = (entryToUpdate: any, param?: any) => Promise<any>;\ntype ParamsTransform = (params: Modules.Documents.Params.All) => Modules.Documents.Params.All;\n\nconst addFirstPublishedAtToDraft = async (\n draft: any,\n update: EntriesUpdate,\n contentType: Schema.ContentType\n) => {\n if (!contentTypes.hasFirstPublishedAtField(contentType)) {\n return draft;\n }\n\n if (draft.firstPublishedAt) {\n return draft;\n }\n\n return update(draft, {\n data: {\n firstPublishedAt: Date.now(),\n },\n });\n};\n\nconst filterDataFirstPublishedAt: ParamsTransform = (params) => {\n if (params?.data?.firstPublishedAt) {\n return assoc(['data', 'firstPublishedAt'], null, params);\n }\n\n return params;\n};\n\nexport { addFirstPublishedAtToDraft, filterDataFirstPublishedAt };\n"],"names":["addFirstPublishedAtToDraft","draft","update","contentType","contentTypes","hasFirstPublishedAtField","firstPublishedAt","data","Date","now","filterDataFirstPublishedAt","params","assoc"],"mappings":";;;;;AAOMA,MAAAA,0BAAAA,GAA6B,OACjCC,KAAAA,EACAC,MACAC,EAAAA,WAAAA,GAAAA;AAEA,IAAA,IAAI,CAACC,wBAAAA,CAAaC,wBAAwB,CAACF,WAAc,CAAA,EAAA;QACvD,OAAOF,KAAAA;AACT;IAEA,IAAIA,KAAAA,CAAMK,gBAAgB,EAAE;QAC1B,OAAOL,KAAAA;AACT;AAEA,IAAA,OAAOC,OAAOD,KAAO,EAAA;QACnBM,IAAM,EAAA;AACJD,YAAAA,gBAAAA,EAAkBE,KAAKC,GAAG;AAC5B;AACF,KAAA,CAAA;AACF;AAEA,MAAMC,6BAA8C,CAACC,MAAAA,GAAAA;IACnD,IAAIA,MAAAA,EAAQJ,MAAMD,gBAAkB,EAAA;AAClC,QAAA,OAAOM,QAAM,CAAA;AAAC,YAAA,MAAA;AAAQ,YAAA;AAAmB,SAAA,EAAE,IAAMD,EAAAA,MAAAA,CAAAA;AACnD;IAEA,OAAOA,MAAAA;AACT;;;;;"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { contentTypes } from '@strapi/utils';
|
|
2
|
+
import { assoc } from 'lodash/fp';
|
|
3
|
+
|
|
4
|
+
const addFirstPublishedAtToDraft = async (draft, update, contentType)=>{
|
|
5
|
+
if (!contentTypes.hasFirstPublishedAtField(contentType)) {
|
|
6
|
+
return draft;
|
|
7
|
+
}
|
|
8
|
+
if (draft.firstPublishedAt) {
|
|
9
|
+
return draft;
|
|
10
|
+
}
|
|
11
|
+
return update(draft, {
|
|
12
|
+
data: {
|
|
13
|
+
firstPublishedAt: Date.now()
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
const filterDataFirstPublishedAt = (params)=>{
|
|
18
|
+
if (params?.data?.firstPublishedAt) {
|
|
19
|
+
return assoc([
|
|
20
|
+
'data',
|
|
21
|
+
'firstPublishedAt'
|
|
22
|
+
], null, params);
|
|
23
|
+
}
|
|
24
|
+
return params;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export { addFirstPublishedAtToDraft, filterDataFirstPublishedAt };
|
|
28
|
+
//# sourceMappingURL=first-published-at.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"first-published-at.mjs","sources":["../../../src/services/document-service/first-published-at.ts"],"sourcesContent":["import { contentTypes } from '@strapi/utils';\nimport { assoc } from 'lodash/fp';\nimport type { Modules, Schema } from '@strapi/types';\n\ntype EntriesUpdate = (entryToUpdate: any, param?: any) => Promise<any>;\ntype ParamsTransform = (params: Modules.Documents.Params.All) => Modules.Documents.Params.All;\n\nconst addFirstPublishedAtToDraft = async (\n draft: any,\n update: EntriesUpdate,\n contentType: Schema.ContentType\n) => {\n if (!contentTypes.hasFirstPublishedAtField(contentType)) {\n return draft;\n }\n\n if (draft.firstPublishedAt) {\n return draft;\n }\n\n return update(draft, {\n data: {\n firstPublishedAt: Date.now(),\n },\n });\n};\n\nconst filterDataFirstPublishedAt: ParamsTransform = (params) => {\n if (params?.data?.firstPublishedAt) {\n return assoc(['data', 'firstPublishedAt'], null, params);\n }\n\n return params;\n};\n\nexport { addFirstPublishedAtToDraft, filterDataFirstPublishedAt };\n"],"names":["addFirstPublishedAtToDraft","draft","update","contentType","contentTypes","hasFirstPublishedAtField","firstPublishedAt","data","Date","now","filterDataFirstPublishedAt","params","assoc"],"mappings":";;;AAOMA,MAAAA,0BAAAA,GAA6B,OACjCC,KAAAA,EACAC,MACAC,EAAAA,WAAAA,GAAAA;AAEA,IAAA,IAAI,CAACC,YAAAA,CAAaC,wBAAwB,CAACF,WAAc,CAAA,EAAA;QACvD,OAAOF,KAAAA;AACT;IAEA,IAAIA,KAAAA,CAAMK,gBAAgB,EAAE;QAC1B,OAAOL,KAAAA;AACT;AAEA,IAAA,OAAOC,OAAOD,KAAO,EAAA;QACnBM,IAAM,EAAA;AACJD,YAAAA,gBAAAA,EAAkBE,KAAKC,GAAG;AAC5B;AACF,KAAA,CAAA;AACF;AAEA,MAAMC,6BAA8C,CAACC,MAAAA,GAAAA;IACnD,IAAIA,MAAAA,EAAQJ,MAAMD,gBAAkB,EAAA;AAClC,QAAA,OAAOM,KAAM,CAAA;AAAC,YAAA,MAAA;AAAQ,YAAA;AAAmB,SAAA,EAAE,IAAMD,EAAAA,MAAAA,CAAAA;AACnD;IAEA,OAAOA,MAAAA;AACT;;;;"}
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
/// <reference types="lodash" />
|
|
2
2
|
import type { Struct, Modules } from '@strapi/types';
|
|
3
|
+
/**
|
|
4
|
+
* Copy non-localized fields from an existing entry to a new entry being created
|
|
5
|
+
* for a different locale of the same document. Returns a new object with the merged data.
|
|
6
|
+
*/
|
|
7
|
+
declare const copyNonLocalizedFields: (contentType: Struct.SingleTypeSchema | Struct.CollectionTypeSchema, documentId: string, dataToCreate: Record<string, any>) => Promise<Record<string, any>>;
|
|
3
8
|
declare const defaultLocaleCurry: import("lodash").CurriedFunction2<Struct.SingleTypeSchema | Struct.CollectionTypeSchema, Modules.Documents.Params.All, Promise<Modules.Documents.Params.All>>;
|
|
4
9
|
declare const localeToLookupCurry: import("lodash").CurriedFunction2<Struct.SingleTypeSchema | Struct.CollectionTypeSchema, Modules.Documents.Params.All, Modules.Documents.Params.All>;
|
|
5
10
|
declare const multiLocaleToLookupCurry: import("lodash").CurriedFunction2<Struct.SingleTypeSchema | Struct.CollectionTypeSchema, Modules.Documents.Params.All, Modules.Documents.Params.All>;
|
|
6
11
|
declare const localeToDataCurry: import("lodash").CurriedFunction2<Struct.SingleTypeSchema | Struct.CollectionTypeSchema, Modules.Documents.Params.All, Modules.Documents.Params.All>;
|
|
7
|
-
export { defaultLocaleCurry as defaultLocale, localeToLookupCurry as localeToLookup, localeToDataCurry as localeToData, multiLocaleToLookupCurry as multiLocaleToLookup, };
|
|
12
|
+
export { defaultLocaleCurry as defaultLocale, localeToLookupCurry as localeToLookup, localeToDataCurry as localeToData, multiLocaleToLookupCurry as multiLocaleToLookup, copyNonLocalizedFields, };
|
|
8
13
|
//# sourceMappingURL=internationalization.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internationalization.d.ts","sourceRoot":"","sources":["../../../src/services/document-service/internationalization.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AA8FrD,QAAA,MAAM,kBAAkB,+JAAuB,CAAC;AAChD,QAAA,MAAM,mBAAmB,sJAAwB,CAAC;AAClD,QAAA,MAAM,wBAAwB,sJAA6B,CAAC;AAC5D,QAAA,MAAM,iBAAiB,sJAAsB,CAAC;AAE9C,OAAO,EACL,kBAAkB,IAAI,aAAa,EACnC,mBAAmB,IAAI,cAAc,EACrC,iBAAiB,IAAI,YAAY,EACjC,wBAAwB,IAAI,mBAAmB,
|
|
1
|
+
{"version":3,"file":"internationalization.d.ts","sourceRoot":"","sources":["../../../src/services/document-service/internationalization.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AA8FrD;;;GAGG;AACH,QAAA,MAAM,sBAAsB,gBACb,OAAO,gBAAgB,GAAG,OAAO,oBAAoB,cACtD,MAAM,gBACJ,OAAO,MAAM,EAAE,GAAG,CAAC,KAChC,QAAQ,OAAO,MAAM,EAAE,GAAG,CAAC,CAwB7B,CAAC;AAEF,QAAA,MAAM,kBAAkB,+JAAuB,CAAC;AAChD,QAAA,MAAM,mBAAmB,sJAAwB,CAAC;AAClD,QAAA,MAAM,wBAAwB,sJAA6B,CAAC;AAC5D,QAAA,MAAM,iBAAiB,sJAAsB,CAAC;AAE9C,OAAO,EACL,kBAAkB,IAAI,aAAa,EACnC,mBAAmB,IAAI,cAAc,EACrC,iBAAiB,IAAI,YAAY,EACjC,wBAAwB,IAAI,mBAAmB,EAC/C,sBAAsB,GACvB,CAAC"}
|
|
@@ -67,11 +67,43 @@ const defaultLocale = async (contentType, params)=>{
|
|
|
67
67
|
}
|
|
68
68
|
return params;
|
|
69
69
|
};
|
|
70
|
+
/**
|
|
71
|
+
* Copy non-localized fields from an existing entry to a new entry being created
|
|
72
|
+
* for a different locale of the same document. Returns a new object with the merged data.
|
|
73
|
+
*/ const copyNonLocalizedFields = async (contentType, documentId, dataToCreate)=>{
|
|
74
|
+
// Check if this is a localized content type and if i18n plugin is available
|
|
75
|
+
const i18nService = strapi.plugin('i18n')?.service('content-types');
|
|
76
|
+
if (!i18nService?.isLocalizedContentType(contentType)) {
|
|
77
|
+
return dataToCreate;
|
|
78
|
+
}
|
|
79
|
+
// Find an existing entry for the same document to copy unlocalized fields from
|
|
80
|
+
const existingEntry = await strapi.db.query(contentType.uid).findOne({
|
|
81
|
+
where: {
|
|
82
|
+
documentId
|
|
83
|
+
},
|
|
84
|
+
// Prefer published entry, but fall back to any entry
|
|
85
|
+
orderBy: {
|
|
86
|
+
publishedAt: 'desc'
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
// If an entry exists in another locale, copy its non-localized fields
|
|
90
|
+
if (existingEntry) {
|
|
91
|
+
const mergedData = {
|
|
92
|
+
...dataToCreate
|
|
93
|
+
};
|
|
94
|
+
i18nService.fillNonLocalizedAttributes(mergedData, existingEntry, {
|
|
95
|
+
model: contentType.uid
|
|
96
|
+
});
|
|
97
|
+
return mergedData;
|
|
98
|
+
}
|
|
99
|
+
return dataToCreate;
|
|
100
|
+
};
|
|
70
101
|
const defaultLocaleCurry = fp.curry(defaultLocale);
|
|
71
102
|
const localeToLookupCurry = fp.curry(localeToLookup);
|
|
72
103
|
const multiLocaleToLookupCurry = fp.curry(multiLocaleToLookup);
|
|
73
104
|
const localeToDataCurry = fp.curry(localeToData);
|
|
74
105
|
|
|
106
|
+
exports.copyNonLocalizedFields = copyNonLocalizedFields;
|
|
75
107
|
exports.defaultLocale = defaultLocaleCurry;
|
|
76
108
|
exports.localeToData = localeToDataCurry;
|
|
77
109
|
exports.localeToLookup = localeToLookupCurry;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internationalization.js","sources":["../../../src/services/document-service/internationalization.ts"],"sourcesContent":["import type { Struct, Modules } from '@strapi/types';\nimport { errors } from '@strapi/utils';\nimport { curry, assoc } from 'lodash/fp';\n\ntype Transform = (\n contentType: Struct.SingleTypeSchema | Struct.CollectionTypeSchema,\n params: Modules.Documents.Params.All\n) => Modules.Documents.Params.All;\n\ntype AsyncTransform = (\n contentType: Struct.SingleTypeSchema | Struct.CollectionTypeSchema,\n params: Modules.Documents.Params.All\n) => Promise<Modules.Documents.Params.All>;\n\nconst getDefaultLocale = async (): Promise<string> => {\n return strapi.plugin('i18n').service('locales').getDefaultLocale();\n};\n\nconst defaultLocale: AsyncTransform = async (contentType, params) => {\n if (!strapi.plugin('i18n').service('content-types').isLocalizedContentType(contentType)) {\n return params;\n }\n\n if (!params.locale) {\n return assoc('locale', await getDefaultLocale(), params);\n }\n\n return params;\n};\n\n/**\n * Add locale lookup query to the params\n */\nconst localeToLookup: Transform = (contentType, params) => {\n if (\n !params.locale ||\n !strapi.plugin('i18n').service('content-types').isLocalizedContentType(contentType)\n ) {\n return params;\n }\n\n if (typeof params.locale !== 'string') {\n // localeToLookup accepts locales of '*'. This is because the document\n // service functions that use this transform work with the '*' locale\n // to return all locales.\n throw new errors.ValidationError(\n `Invalid locale param ${String(params.locale)} provided. Document locales must be strings.`\n );\n }\n\n return assoc(['lookup', 'locale'], params.locale, params);\n};\n\n/**\n * Add locale lookup query to the params\n */\nconst multiLocaleToLookup: Transform = (contentType, params) => {\n if (!strapi.plugin('i18n').service('content-types').isLocalizedContentType(contentType)) {\n return params;\n }\n\n if (params.locale) {\n if (params.locale === '*') {\n return params;\n }\n\n return assoc(['lookup', 'locale'], params.locale, params);\n }\n\n return params;\n};\n\n/**\n * Translate locale status parameter into the data that will be saved\n */\nconst localeToData: Transform = (contentType, params) => {\n if (!strapi.plugin('i18n').service('content-types').isLocalizedContentType(contentType)) {\n return params;\n }\n\n if (params.locale) {\n const isValidLocale = typeof params.locale === 'string' && params.locale !== '*';\n if (isValidLocale) {\n return assoc(['data', 'locale'], params.locale, params);\n }\n\n throw new errors.ValidationError(\n `Invalid locale param ${params.locale} provided. Document locales must be strings.`\n );\n }\n\n return params;\n};\n\nconst defaultLocaleCurry = curry(defaultLocale);\nconst localeToLookupCurry = curry(localeToLookup);\nconst multiLocaleToLookupCurry = curry(multiLocaleToLookup);\nconst localeToDataCurry = curry(localeToData);\n\nexport {\n defaultLocaleCurry as defaultLocale,\n localeToLookupCurry as localeToLookup,\n localeToDataCurry as localeToData,\n multiLocaleToLookupCurry as multiLocaleToLookup,\n};\n"],"names":["getDefaultLocale","strapi","plugin","service","defaultLocale","contentType","params","isLocalizedContentType","locale","assoc","localeToLookup","errors","ValidationError","String","multiLocaleToLookup","localeToData","isValidLocale","defaultLocaleCurry","curry","localeToLookupCurry","multiLocaleToLookupCurry","localeToDataCurry"],"mappings":";;;;;AAcA,MAAMA,gBAAmB,GAAA,UAAA;AACvB,IAAA,OAAOC,OAAOC,MAAM,CAAC,QAAQC,OAAO,CAAC,WAAWH,gBAAgB,EAAA;AAClE,CAAA;AAEA,MAAMI,aAAAA,GAAgC,OAAOC,WAAaC,EAAAA,MAAAA,GAAAA;IACxD,IAAI,CAACL,MAAOC,CAAAA,MAAM,CAAC,MAAA,CAAA,CAAQC,OAAO,CAAC,eAAA,CAAA,CAAiBI,sBAAsB,CAACF,WAAc,CAAA,EAAA;QACvF,OAAOC,MAAAA;AACT;IAEA,IAAI,CAACA,MAAOE,CAAAA,MAAM,EAAE;QAClB,OAAOC,QAAAA,CAAM,QAAU,EAAA,MAAMT,gBAAoBM,EAAAA,EAAAA,MAAAA,CAAAA;AACnD;IAEA,OAAOA,MAAAA;AACT,CAAA;AAEA;;IAGA,MAAMI,cAA4B,GAAA,CAACL,WAAaC,EAAAA,MAAAA,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AA,EAAA;QACvF,OAAOC,MAAAA;AACT;IAEA,IAAIA,MAAAA,CAAOE,MAAM,EAAE;QACjB,MAAMQ,aAAAA,GAAgB,OAAOV,MAAOE,CAAAA,MAAM,KAAK,QAAYF,IAAAA,MAAAA,CAAOE,MAAM,KAAK,GAAA;AAC7E,QAAA,IAAIQ,aAAe,EAAA;AACjB,YAAA,OAAOP,QAAM,CAAA;AAAC,gBAAA,MAAA;AAAQ,gBAAA;aAAS,EAAEH,MAAAA,CAAOE,MAAM,EAAEF,MAAAA,CAAAA;AAClD;QAEA,MAAM,IAAIK,kBAAOC,CAAAA,eAAe,CAC9B,CAAC,qBAAqB,EAAEN,MAAOE,CAAAA,MAAM,CAAC,4CAA4C,CAAC,CAAA;AAEvF;IAEA,OAAOF,MAAAA;AACT,CAAA;AAEA,
|
|
1
|
+
{"version":3,"file":"internationalization.js","sources":["../../../src/services/document-service/internationalization.ts"],"sourcesContent":["import type { Struct, Modules } from '@strapi/types';\nimport { errors } from '@strapi/utils';\nimport { curry, assoc } from 'lodash/fp';\n\ntype Transform = (\n contentType: Struct.SingleTypeSchema | Struct.CollectionTypeSchema,\n params: Modules.Documents.Params.All\n) => Modules.Documents.Params.All;\n\ntype AsyncTransform = (\n contentType: Struct.SingleTypeSchema | Struct.CollectionTypeSchema,\n params: Modules.Documents.Params.All\n) => Promise<Modules.Documents.Params.All>;\n\nconst getDefaultLocale = async (): Promise<string> => {\n return strapi.plugin('i18n').service('locales').getDefaultLocale();\n};\n\nconst defaultLocale: AsyncTransform = async (contentType, params) => {\n if (!strapi.plugin('i18n').service('content-types').isLocalizedContentType(contentType)) {\n return params;\n }\n\n if (!params.locale) {\n return assoc('locale', await getDefaultLocale(), params);\n }\n\n return params;\n};\n\n/**\n * Add locale lookup query to the params\n */\nconst localeToLookup: Transform = (contentType, params) => {\n if (\n !params.locale ||\n !strapi.plugin('i18n').service('content-types').isLocalizedContentType(contentType)\n ) {\n return params;\n }\n\n if (typeof params.locale !== 'string') {\n // localeToLookup accepts locales of '*'. This is because the document\n // service functions that use this transform work with the '*' locale\n // to return all locales.\n throw new errors.ValidationError(\n `Invalid locale param ${String(params.locale)} provided. Document locales must be strings.`\n );\n }\n\n return assoc(['lookup', 'locale'], params.locale, params);\n};\n\n/**\n * Add locale lookup query to the params\n */\nconst multiLocaleToLookup: Transform = (contentType, params) => {\n if (!strapi.plugin('i18n').service('content-types').isLocalizedContentType(contentType)) {\n return params;\n }\n\n if (params.locale) {\n if (params.locale === '*') {\n return params;\n }\n\n return assoc(['lookup', 'locale'], params.locale, params);\n }\n\n return params;\n};\n\n/**\n * Translate locale status parameter into the data that will be saved\n */\nconst localeToData: Transform = (contentType, params) => {\n if (!strapi.plugin('i18n').service('content-types').isLocalizedContentType(contentType)) {\n return params;\n }\n\n if (params.locale) {\n const isValidLocale = typeof params.locale === 'string' && params.locale !== '*';\n if (isValidLocale) {\n return assoc(['data', 'locale'], params.locale, params);\n }\n\n throw new errors.ValidationError(\n `Invalid locale param ${params.locale} provided. Document locales must be strings.`\n );\n }\n\n return params;\n};\n\n/**\n * Copy non-localized fields from an existing entry to a new entry being created\n * for a different locale of the same document. Returns a new object with the merged data.\n */\nconst copyNonLocalizedFields = async (\n contentType: Struct.SingleTypeSchema | Struct.CollectionTypeSchema,\n documentId: string,\n dataToCreate: Record<string, any>\n): Promise<Record<string, any>> => {\n // Check if this is a localized content type and if i18n plugin is available\n const i18nService = strapi.plugin('i18n')?.service('content-types');\n if (!i18nService?.isLocalizedContentType(contentType)) {\n return dataToCreate;\n }\n\n // Find an existing entry for the same document to copy unlocalized fields from\n const existingEntry = await strapi.db.query(contentType.uid).findOne({\n where: { documentId },\n // Prefer published entry, but fall back to any entry\n orderBy: { publishedAt: 'desc' },\n });\n\n // If an entry exists in another locale, copy its non-localized fields\n if (existingEntry) {\n const mergedData = { ...dataToCreate };\n i18nService.fillNonLocalizedAttributes(mergedData, existingEntry, {\n model: contentType.uid,\n });\n return mergedData;\n }\n\n return dataToCreate;\n};\n\nconst defaultLocaleCurry = curry(defaultLocale);\nconst localeToLookupCurry = curry(localeToLookup);\nconst multiLocaleToLookupCurry = curry(multiLocaleToLookup);\nconst localeToDataCurry = curry(localeToData);\n\nexport {\n defaultLocaleCurry as defaultLocale,\n localeToLookupCurry as localeToLookup,\n localeToDataCurry as localeToData,\n multiLocaleToLookupCurry as multiLocaleToLookup,\n copyNonLocalizedFields,\n};\n"],"names":["getDefaultLocale","strapi","plugin","service","defaultLocale","contentType","params","isLocalizedContentType","locale","assoc","localeToLookup","errors","ValidationError","String","multiLocaleToLookup","localeToData","isValidLocale","copyNonLocalizedFields","documentId","dataToCreate","i18nService","existingEntry","db","query","uid","findOne","where","orderBy","publishedAt","mergedData","fillNonLocalizedAttributes","model","defaultLocaleCurry","curry","localeToLookupCurry","multiLocaleToLookupCurry","localeToDataCurry"],"mappings":";;;;;AAcA,MAAMA,gBAAmB,GAAA,UAAA;AACvB,IAAA,OAAOC,OAAOC,MAAM,CAAC,QAAQC,OAAO,CAAC,WAAWH,gBAAgB,EAAA;AAClE,CAAA;AAEA,MAAMI,aAAAA,GAAgC,OAAOC,WAAaC,EAAAA,MAAAA,GAAAA;IACxD,IAAI,CAACL,MAAOC,CAAAA,MAAM,CAAC,MAAA,CAAA,CAAQC,OAAO,CAAC,eAAA,CAAA,CAAiBI,sBAAsB,CAACF,WAAc,CAAA,EAAA;QACvF,OAAOC,MAAAA;AACT;IAEA,IAAI,CAACA,MAAOE,CAAAA,MAAM,EAAE;QAClB,OAAOC,QAAAA,CAAM,QAAU,EAAA,MAAMT,gBAAoBM,EAAAA,EAAAA,MAAAA,CAAAA;AACnD;IAEA,OAAOA,MAAAA;AACT,CAAA;AAEA;;IAGA,MAAMI,cAA4B,GAAA,CAACL,WAAaC,EAAAA,MAAAA,GAAAA;AAC9C,IAAA,IACE,CAACA,MAAAA,CAAOE,MAAM,IACd,CAACP,MAAOC,CAAAA,MAAM,CAAC,MAAA,CAAA,CAAQC,OAAO,CAAC,eAAiBI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AAA,cAAAA;AAClC,MAAMyB,2BAA2BF,QAAMnB,CAAAA,mBAAAA;AACvC,MAAMsB,oBAAoBH,QAAMlB,CAAAA,YAAAA;;;;;;;;"}
|
|
@@ -65,10 +65,41 @@ const defaultLocale = async (contentType, params)=>{
|
|
|
65
65
|
}
|
|
66
66
|
return params;
|
|
67
67
|
};
|
|
68
|
+
/**
|
|
69
|
+
* Copy non-localized fields from an existing entry to a new entry being created
|
|
70
|
+
* for a different locale of the same document. Returns a new object with the merged data.
|
|
71
|
+
*/ const copyNonLocalizedFields = async (contentType, documentId, dataToCreate)=>{
|
|
72
|
+
// Check if this is a localized content type and if i18n plugin is available
|
|
73
|
+
const i18nService = strapi.plugin('i18n')?.service('content-types');
|
|
74
|
+
if (!i18nService?.isLocalizedContentType(contentType)) {
|
|
75
|
+
return dataToCreate;
|
|
76
|
+
}
|
|
77
|
+
// Find an existing entry for the same document to copy unlocalized fields from
|
|
78
|
+
const existingEntry = await strapi.db.query(contentType.uid).findOne({
|
|
79
|
+
where: {
|
|
80
|
+
documentId
|
|
81
|
+
},
|
|
82
|
+
// Prefer published entry, but fall back to any entry
|
|
83
|
+
orderBy: {
|
|
84
|
+
publishedAt: 'desc'
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
// If an entry exists in another locale, copy its non-localized fields
|
|
88
|
+
if (existingEntry) {
|
|
89
|
+
const mergedData = {
|
|
90
|
+
...dataToCreate
|
|
91
|
+
};
|
|
92
|
+
i18nService.fillNonLocalizedAttributes(mergedData, existingEntry, {
|
|
93
|
+
model: contentType.uid
|
|
94
|
+
});
|
|
95
|
+
return mergedData;
|
|
96
|
+
}
|
|
97
|
+
return dataToCreate;
|
|
98
|
+
};
|
|
68
99
|
const defaultLocaleCurry = curry(defaultLocale);
|
|
69
100
|
const localeToLookupCurry = curry(localeToLookup);
|
|
70
101
|
const multiLocaleToLookupCurry = curry(multiLocaleToLookup);
|
|
71
102
|
const localeToDataCurry = curry(localeToData);
|
|
72
103
|
|
|
73
|
-
export { defaultLocaleCurry as defaultLocale, localeToDataCurry as localeToData, localeToLookupCurry as localeToLookup, multiLocaleToLookupCurry as multiLocaleToLookup };
|
|
104
|
+
export { copyNonLocalizedFields, defaultLocaleCurry as defaultLocale, localeToDataCurry as localeToData, localeToLookupCurry as localeToLookup, multiLocaleToLookupCurry as multiLocaleToLookup };
|
|
74
105
|
//# sourceMappingURL=internationalization.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internationalization.mjs","sources":["../../../src/services/document-service/internationalization.ts"],"sourcesContent":["import type { Struct, Modules } from '@strapi/types';\nimport { errors } from '@strapi/utils';\nimport { curry, assoc } from 'lodash/fp';\n\ntype Transform = (\n contentType: Struct.SingleTypeSchema | Struct.CollectionTypeSchema,\n params: Modules.Documents.Params.All\n) => Modules.Documents.Params.All;\n\ntype AsyncTransform = (\n contentType: Struct.SingleTypeSchema | Struct.CollectionTypeSchema,\n params: Modules.Documents.Params.All\n) => Promise<Modules.Documents.Params.All>;\n\nconst getDefaultLocale = async (): Promise<string> => {\n return strapi.plugin('i18n').service('locales').getDefaultLocale();\n};\n\nconst defaultLocale: AsyncTransform = async (contentType, params) => {\n if (!strapi.plugin('i18n').service('content-types').isLocalizedContentType(contentType)) {\n return params;\n }\n\n if (!params.locale) {\n return assoc('locale', await getDefaultLocale(), params);\n }\n\n return params;\n};\n\n/**\n * Add locale lookup query to the params\n */\nconst localeToLookup: Transform = (contentType, params) => {\n if (\n !params.locale ||\n !strapi.plugin('i18n').service('content-types').isLocalizedContentType(contentType)\n ) {\n return params;\n }\n\n if (typeof params.locale !== 'string') {\n // localeToLookup accepts locales of '*'. This is because the document\n // service functions that use this transform work with the '*' locale\n // to return all locales.\n throw new errors.ValidationError(\n `Invalid locale param ${String(params.locale)} provided. Document locales must be strings.`\n );\n }\n\n return assoc(['lookup', 'locale'], params.locale, params);\n};\n\n/**\n * Add locale lookup query to the params\n */\nconst multiLocaleToLookup: Transform = (contentType, params) => {\n if (!strapi.plugin('i18n').service('content-types').isLocalizedContentType(contentType)) {\n return params;\n }\n\n if (params.locale) {\n if (params.locale === '*') {\n return params;\n }\n\n return assoc(['lookup', 'locale'], params.locale, params);\n }\n\n return params;\n};\n\n/**\n * Translate locale status parameter into the data that will be saved\n */\nconst localeToData: Transform = (contentType, params) => {\n if (!strapi.plugin('i18n').service('content-types').isLocalizedContentType(contentType)) {\n return params;\n }\n\n if (params.locale) {\n const isValidLocale = typeof params.locale === 'string' && params.locale !== '*';\n if (isValidLocale) {\n return assoc(['data', 'locale'], params.locale, params);\n }\n\n throw new errors.ValidationError(\n `Invalid locale param ${params.locale} provided. Document locales must be strings.`\n );\n }\n\n return params;\n};\n\nconst defaultLocaleCurry = curry(defaultLocale);\nconst localeToLookupCurry = curry(localeToLookup);\nconst multiLocaleToLookupCurry = curry(multiLocaleToLookup);\nconst localeToDataCurry = curry(localeToData);\n\nexport {\n defaultLocaleCurry as defaultLocale,\n localeToLookupCurry as localeToLookup,\n localeToDataCurry as localeToData,\n multiLocaleToLookupCurry as multiLocaleToLookup,\n};\n"],"names":["getDefaultLocale","strapi","plugin","service","defaultLocale","contentType","params","isLocalizedContentType","locale","assoc","localeToLookup","errors","ValidationError","String","multiLocaleToLookup","localeToData","isValidLocale","defaultLocaleCurry","curry","localeToLookupCurry","multiLocaleToLookupCurry","localeToDataCurry"],"mappings":";;;AAcA,MAAMA,gBAAmB,GAAA,UAAA;AACvB,IAAA,OAAOC,OAAOC,MAAM,CAAC,QAAQC,OAAO,CAAC,WAAWH,gBAAgB,EAAA;AAClE,CAAA;AAEA,MAAMI,aAAAA,GAAgC,OAAOC,WAAaC,EAAAA,MAAAA,GAAAA;IACxD,IAAI,CAACL,MAAOC,CAAAA,MAAM,CAAC,MAAA,CAAA,CAAQC,OAAO,CAAC,eAAA,CAAA,CAAiBI,sBAAsB,CAACF,WAAc,CAAA,EAAA;QACvF,OAAOC,MAAAA;AACT;IAEA,IAAI,CAACA,MAAOE,CAAAA,M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AA;AAEA;;IAGA,MAAMS,YAA0B,GAAA,CAACV,WAAaC,EAAAA,MAAAA,GAAAA;IAC5C,IAAI,CAACL,MAAOC,CAAAA,MAAM,CAAC,MAAA,CAAA,CAAQC,OAAO,CAAC,eAAA,CAAA,CAAiBI,sBAAsB,CAACF,WAAc,CAAA,EAAA;QACvF,OAAOC,MAAAA;AACT;IAEA,IAAIA,MAAAA,CAAOE,MAAM,EAAE;QACjB,MAAMQ,aAAAA,GAAgB,OAAOV,MAAOE,CAAAA,MAAM,KAAK,QAAYF,IAAAA,MAAAA,CAAOE,MAAM,KAAK,GAAA;AAC7E,QAAA,IAAIQ,aAAe,EAAA;AACjB,YAAA,OAAOP,KAAM,CAAA;AAAC,gBAAA,MAAA;AAAQ,gBAAA;aAAS,EAAEH,MAAAA,CAAOE,MAAM,EAAEF,MAAAA,CAAAA;AAClD;QAEA,MAAM,IAAIK,MAAOC,CAAAA,eAAe,CAC9B,CAAC,qBAAqB,EAAEN,MAAOE,CAAAA,MAAM,CAAC,4CAA4C,CAAC,CAAA;AAEvF;IAEA,OAAOF,MAAAA;AACT,CAAA;AAEA,
|
|
1
|
+
{"version":3,"file":"internationalization.mjs","sources":["../../../src/services/document-service/internationalization.ts"],"sourcesContent":["import type { Struct, Modules } from '@strapi/types';\nimport { errors } from '@strapi/utils';\nimport { curry, assoc } from 'lodash/fp';\n\ntype Transform = (\n contentType: Struct.SingleTypeSchema | Struct.CollectionTypeSchema,\n params: Modules.Documents.Params.All\n) => Modules.Documents.Params.All;\n\ntype AsyncTransform = (\n contentType: Struct.SingleTypeSchema | Struct.CollectionTypeSchema,\n params: Modules.Documents.Params.All\n) => Promise<Modules.Documents.Params.All>;\n\nconst getDefaultLocale = async (): Promise<string> => {\n return strapi.plugin('i18n').service('locales').getDefaultLocale();\n};\n\nconst defaultLocale: AsyncTransform = async (contentType, params) => {\n if (!strapi.plugin('i18n').service('content-types').isLocalizedContentType(contentType)) {\n return params;\n }\n\n if (!params.locale) {\n return assoc('locale', await getDefaultLocale(), params);\n }\n\n return params;\n};\n\n/**\n * Add locale lookup query to the params\n */\nconst localeToLookup: Transform = (contentType, params) => {\n if (\n !params.locale ||\n !strapi.plugin('i18n').service('content-types').isLocalizedContentType(contentType)\n ) {\n return params;\n }\n\n if (typeof params.locale !== 'string') {\n // localeToLookup accepts locales of '*'. This is because the document\n // service functions that use this transform work with the '*' locale\n // to return all locales.\n throw new errors.ValidationError(\n `Invalid locale param ${String(params.locale)} provided. Document locales must be strings.`\n );\n }\n\n return assoc(['lookup', 'locale'], params.locale, params);\n};\n\n/**\n * Add locale lookup query to the params\n */\nconst multiLocaleToLookup: Transform = (contentType, params) => {\n if (!strapi.plugin('i18n').service('content-types').isLocalizedContentType(contentType)) {\n return params;\n }\n\n if (params.locale) {\n if (params.locale === '*') {\n return params;\n }\n\n return assoc(['lookup', 'locale'], params.locale, params);\n }\n\n return params;\n};\n\n/**\n * Translate locale status parameter into the data that will be saved\n */\nconst localeToData: Transform = (contentType, params) => {\n if (!strapi.plugin('i18n').service('content-types').isLocalizedContentType(contentType)) {\n return params;\n }\n\n if (params.locale) {\n const isValidLocale = typeof params.locale === 'string' && params.locale !== '*';\n if (isValidLocale) {\n return assoc(['data', 'locale'], params.locale, params);\n }\n\n throw new errors.ValidationError(\n `Invalid locale param ${params.locale} provided. Document locales must be strings.`\n );\n }\n\n return params;\n};\n\n/**\n * Copy non-localized fields from an existing entry to a new entry being created\n * for a different locale of the same document. Returns a new object with the merged data.\n */\nconst copyNonLocalizedFields = async (\n contentType: Struct.SingleTypeSchema | Struct.CollectionTypeSchema,\n documentId: string,\n dataToCreate: Record<string, any>\n): Promise<Record<string, any>> => {\n // Check if this is a localized content type and if i18n plugin is available\n const i18nService = strapi.plugin('i18n')?.service('content-types');\n if (!i18nService?.isLocalizedContentType(contentType)) {\n return dataToCreate;\n }\n\n // Find an existing entry for the same document to copy unlocalized fields from\n const existingEntry = await strapi.db.query(contentType.uid).findOne({\n where: { documentId },\n // Prefer published entry, but fall back to any entry\n orderBy: { publishedAt: 'desc' },\n });\n\n // If an entry exists in another locale, copy its non-localized fields\n if (existingEntry) {\n const mergedData = { ...dataToCreate };\n i18nService.fillNonLocalizedAttributes(mergedData, existingEntry, {\n model: contentType.uid,\n });\n return mergedData;\n }\n\n return dataToCreate;\n};\n\nconst defaultLocaleCurry = curry(defaultLocale);\nconst localeToLookupCurry = curry(localeToLookup);\nconst multiLocaleToLookupCurry = curry(multiLocaleToLookup);\nconst localeToDataCurry = curry(localeToData);\n\nexport {\n defaultLocaleCurry as defaultLocale,\n localeToLookupCurry as localeToLookup,\n localeToDataCurry as localeToData,\n multiLocaleToLookupCurry as multiLocaleToLookup,\n copyNonLocalizedFields,\n};\n"],"names":["getDefaultLocale","strapi","plugin","service","defaultLocale","contentType","params","isLocalizedContentType","locale","assoc","localeToLookup","errors","ValidationError","String","multiLocaleToLookup","localeToData","isValidLocale","copyNonLocalizedFields","documentId","dataToCreate","i18nService","existingEntry","db","query","uid","findOne","where","orderBy","publishedAt","mergedData","fillNonLocalizedAttributes","model","defaultLocaleCurry","curry","localeToLookupCurry","multiLocaleToLookupCurry","localeToDataCurry"],"mappings":";;;AAcA,MAAMA,gBAAmB,GAAA,UAAA;AACvB,IAAA,OAAOC,OAAOC,MAAM,CAAC,QAAQC,OAAO,CAAC,WAAWH,gBAAgB,EAAA;AAClE,CAAA;AAEA,MAAMI,aAAAA,GAAgC,OAAOC,WAAaC,EAAAA,MAAAA,GAAAA;IACxD,IAAI,CAACL,MAAOC,CAAAA,MAAM,CAAC,MAAA,CAAA,CAAQC,OAAO,CAAC,eAAA,CAAA,CAAiBI,sBAAsB,CAACF,WAAc,CAAA,EAAA;QACvF,OAAOC,MAAAA;AACT;IAEA,IAAI,CAACA,MAAOE,CAAAA,MAAM,EAAE;QAClB,OAAOC,KAAAA,CAAM,QAAU,EAAA,MAAMT,gBAAoBM,EAAAA,EAAAA,MAAAA,CAAAA;AACnD;IAEA,OAAOA,MAAAA;AACT,CAA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A;AAChEU,YAAAA,KAAAA,EAAO1B,YAAYmB;AACrB,SAAA,CAAA;QACA,OAAOK,UAAAA;AACT;IAEA,OAAOV,YAAAA;AACT;AAEA,MAAMa,qBAAqBC,KAAM7B,CAAAA,aAAAA;AACjC,MAAM8B,sBAAsBD,KAAMvB,CAAAA,cAAAA;AAClC,MAAMyB,2BAA2BF,KAAMnB,CAAAA,mBAAAA;AACvC,MAAMsB,oBAAoBH,KAAMlB,CAAAA,YAAAA;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"repository.d.ts","sourceRoot":"","sources":["../../../src/services/document-service/repository.ts"],"names":[],"mappings":"AAKA,OAAO,EAAqB,KAAK,uBAAuB,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"repository.d.ts","sourceRoot":"","sources":["../../../src/services/document-service/repository.ts"],"names":[],"mappings":"AAKA,OAAO,EAAqB,KAAK,uBAAuB,EAAE,MAAM,UAAU,CAAC;AAuB3E,eAAO,MAAM,2BAA2B,EAAE,uBAgbzC,CAAC"}
|