@primershop/strapi-plugin-product-actions 0.0.12 → 0.0.14
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.
- package/dist/admin/index.js +221 -24
- package/dist/admin/index.mjs +223 -23
- package/dist/server/index.js +242 -17
- package/dist/server/index.mjs +245 -17
- package/package.json +11 -10
- package/dist/admin/components/Initializer/index.js +0 -17
- package/dist/admin/components/Initializer/index.js.map +0 -1
- package/dist/admin/components/Initializer/index.mjs +0 -15
- package/dist/admin/components/Initializer/index.mjs.map +0 -1
- package/dist/admin/components/SeriesProductActions/index.js +0 -229
- package/dist/admin/components/SeriesProductActions/index.js.map +0 -1
- package/dist/admin/components/SeriesProductActions/index.mjs +0 -227
- package/dist/admin/components/SeriesProductActions/index.mjs.map +0 -1
- package/dist/admin/index.js.map +0 -1
- package/dist/admin/index.mjs.map +0 -1
- package/dist/admin/pluginId.js +0 -6
- package/dist/admin/pluginId.js.map +0 -1
- package/dist/admin/pluginId.mjs +0 -4
- package/dist/admin/pluginId.mjs.map +0 -1
- package/dist/admin/translations/en.js +0 -25
- package/dist/admin/translations/en.js.map +0 -1
- package/dist/admin/translations/en.mjs +0 -23
- package/dist/admin/translations/en.mjs.map +0 -1
- package/dist/server/bootstrap.js +0 -16
- package/dist/server/bootstrap.js.map +0 -1
- package/dist/server/bootstrap.mjs +0 -14
- package/dist/server/bootstrap.mjs.map +0 -1
- package/dist/server/controllers/index.js +0 -10
- package/dist/server/controllers/index.js.map +0 -1
- package/dist/server/controllers/index.mjs +0 -8
- package/dist/server/controllers/index.mjs.map +0 -1
- package/dist/server/controllers/product-series.js +0 -29
- package/dist/server/controllers/product-series.js.map +0 -1
- package/dist/server/controllers/product-series.mjs +0 -27
- package/dist/server/controllers/product-series.mjs.map +0 -1
- package/dist/server/index.js.map +0 -1
- package/dist/server/index.mjs.map +0 -1
- package/dist/server/permissions.js +0 -51
- package/dist/server/permissions.js.map +0 -1
- package/dist/server/permissions.mjs +0 -49
- package/dist/server/permissions.mjs.map +0 -1
- package/dist/server/register.js +0 -7
- package/dist/server/register.js.map +0 -1
- package/dist/server/register.mjs +0 -5
- package/dist/server/register.mjs.map +0 -1
- package/dist/server/routes/admin.js +0 -44
- package/dist/server/routes/admin.js.map +0 -1
- package/dist/server/routes/admin.mjs +0 -42
- package/dist/server/routes/admin.mjs.map +0 -1
- package/dist/server/routes/index.js +0 -10
- package/dist/server/routes/index.js.map +0 -1
- package/dist/server/routes/index.mjs +0 -8
- package/dist/server/routes/index.mjs.map +0 -1
- package/dist/server/services/index.js +0 -10
- package/dist/server/services/index.js.map +0 -1
- package/dist/server/services/index.mjs +0 -8
- package/dist/server/services/index.mjs.map +0 -1
- package/dist/server/services/product-series.js +0 -113
- package/dist/server/services/product-series.js.map +0 -1
- package/dist/server/services/product-series.mjs +0 -111
- package/dist/server/services/product-series.mjs.map +0 -1
package/dist/server/bootstrap.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var permissions = require('./permissions.js');
|
|
4
|
-
|
|
5
|
-
const bootstrap = async ({ strapi })=>{
|
|
6
|
-
try {
|
|
7
|
-
strapi.admin.services.permission.actionProvider.registerMany(permissions.permissions.actions);
|
|
8
|
-
strapi.log.info(`[primershop-product-actions] Registered ${permissions.permissions.actions.length} permission actions`);
|
|
9
|
-
} catch (error) {
|
|
10
|
-
strapi.log.error("[primershop-product-actions] Failed to register permissions:", error);
|
|
11
|
-
throw error;
|
|
12
|
-
}
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
module.exports = bootstrap;
|
|
16
|
-
//# sourceMappingURL=bootstrap.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bootstrap.js","sources":["../../server/src/bootstrap.ts"],"sourcesContent":["import { permissions } from \"./permissions\";\r\nimport type { Core } from \"@strapi/strapi\";\r\n\r\nconst bootstrap = async ({ strapi }: { strapi: Core.Strapi }) => {\r\n try {\r\n strapi.admin.services.permission.actionProvider.registerMany(\r\n permissions.actions\r\n );\r\n strapi.log.info(\r\n `[primershop-product-actions] Registered ${permissions.actions.length} permission actions`\r\n );\r\n } catch (error) {\r\n strapi.log.error(\r\n \"[primershop-product-actions] Failed to register permissions:\",\r\n error\r\n );\r\n throw error;\r\n }\r\n};\r\n\r\nexport default bootstrap;\r\n"],"names":["bootstrap","strapi","admin","services","permission","actionProvider","registerMany","permissions","actions","log","info","length","error"],"mappings":";;;;AAGA,MAAMA,SAAAA,GAAY,OAAO,EAAEC,MAAM,EAA2B,GAAA;IAC1D,IAAI;QACFA,MAAAA,CAAOC,KAAK,CAACC,QAAQ,CAACC,UAAU,CAACC,cAAc,CAACC,YAAY,CAC1DC,uBAAAA,CAAYC,OAAO,CAAA;AAErBP,QAAAA,MAAAA,CAAOQ,GAAG,CAACC,IAAI,CACb,CAAC,wCAAwC,EAAEH,uBAAAA,CAAYC,OAAO,CAACG,MAAM,CAAC,mBAAmB,CAAC,CAAA;AAE9F,IAAA,CAAA,CAAE,OAAOC,KAAAA,EAAO;AACdX,QAAAA,MAAAA,CAAOQ,GAAG,CAACG,KAAK,CACd,8DAAA,EACAA,KAAAA,CAAAA;QAEF,MAAMA,KAAAA;AACR,IAAA;AACF;;;;"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { permissions } from './permissions.mjs';
|
|
2
|
-
|
|
3
|
-
const bootstrap = async ({ strapi })=>{
|
|
4
|
-
try {
|
|
5
|
-
strapi.admin.services.permission.actionProvider.registerMany(permissions.actions);
|
|
6
|
-
strapi.log.info(`[primershop-product-actions] Registered ${permissions.actions.length} permission actions`);
|
|
7
|
-
} catch (error) {
|
|
8
|
-
strapi.log.error("[primershop-product-actions] Failed to register permissions:", error);
|
|
9
|
-
throw error;
|
|
10
|
-
}
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export { bootstrap as default };
|
|
14
|
-
//# sourceMappingURL=bootstrap.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bootstrap.mjs","sources":["../../server/src/bootstrap.ts"],"sourcesContent":["import { permissions } from \"./permissions\";\r\nimport type { Core } from \"@strapi/strapi\";\r\n\r\nconst bootstrap = async ({ strapi }: { strapi: Core.Strapi }) => {\r\n try {\r\n strapi.admin.services.permission.actionProvider.registerMany(\r\n permissions.actions\r\n );\r\n strapi.log.info(\r\n `[primershop-product-actions] Registered ${permissions.actions.length} permission actions`\r\n );\r\n } catch (error) {\r\n strapi.log.error(\r\n \"[primershop-product-actions] Failed to register permissions:\",\r\n error\r\n );\r\n throw error;\r\n }\r\n};\r\n\r\nexport default bootstrap;\r\n"],"names":["bootstrap","strapi","admin","services","permission","actionProvider","registerMany","permissions","actions","log","info","length","error"],"mappings":";;AAGA,MAAMA,SAAAA,GAAY,OAAO,EAAEC,MAAM,EAA2B,GAAA;IAC1D,IAAI;QACFA,MAAAA,CAAOC,KAAK,CAACC,QAAQ,CAACC,UAAU,CAACC,cAAc,CAACC,YAAY,CAC1DC,WAAAA,CAAYC,OAAO,CAAA;AAErBP,QAAAA,MAAAA,CAAOQ,GAAG,CAACC,IAAI,CACb,CAAC,wCAAwC,EAAEH,WAAAA,CAAYC,OAAO,CAACG,MAAM,CAAC,mBAAmB,CAAC,CAAA;AAE9F,IAAA,CAAA,CAAE,OAAOC,KAAAA,EAAO;AACdX,QAAAA,MAAAA,CAAOQ,GAAG,CAACG,KAAK,CACd,8DAAA,EACAA,KAAAA,CAAAA;QAEF,MAAMA,KAAAA;AACR,IAAA;AACF;;;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../server/src/controllers/index.ts"],"sourcesContent":["import productSeries from \"./product-series\";\r\n\r\nexport const controllers = {\r\n productSeries,\r\n};\r\n"],"names":["controllers","productSeries"],"mappings":";;;;MAEaA,WAAAA,GAAc;AACzBC,IAAAA;AACF;;;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../../../server/src/controllers/index.ts"],"sourcesContent":["import productSeries from \"./product-series\";\r\n\r\nexport const controllers = {\r\n productSeries,\r\n};\r\n"],"names":["controllers","productSeries"],"mappings":";;MAEaA,WAAAA,GAAc;AACzBC,IAAAA;AACF;;;;"}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const productSeries = ({ strapi })=>({
|
|
4
|
-
async createProducts (ctx) {
|
|
5
|
-
try {
|
|
6
|
-
const { id, count = 1 } = ctx.request.body;
|
|
7
|
-
const products = await strapi.plugin("primershop-product-actions").service("productSeries").createProductsFromSeries(id, count);
|
|
8
|
-
return {
|
|
9
|
-
data: products
|
|
10
|
-
};
|
|
11
|
-
} catch (error) {
|
|
12
|
-
ctx.throw(500, error);
|
|
13
|
-
}
|
|
14
|
-
},
|
|
15
|
-
async updateProducts (ctx) {
|
|
16
|
-
try {
|
|
17
|
-
const { seriesId, fieldsToUpdate } = ctx.request.body;
|
|
18
|
-
await strapi.plugin("primershop-product-actions").service("productSeries").updateSeriesProducts(seriesId, fieldsToUpdate);
|
|
19
|
-
return {
|
|
20
|
-
success: true
|
|
21
|
-
};
|
|
22
|
-
} catch (error) {
|
|
23
|
-
ctx.throw(500, error);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
module.exports = productSeries;
|
|
29
|
-
//# sourceMappingURL=product-series.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"product-series.js","sources":["../../../server/src/controllers/product-series.ts"],"sourcesContent":["import type { Core } from \"@strapi/strapi\";\r\nimport type { Context } from \"koa\";\r\n\r\nconst productSeries = ({\r\n strapi,\r\n}: {\r\n strapi: Core.Strapi;\r\n}): Core.Controller => ({\r\n async createProducts(ctx: Context) {\r\n try {\r\n const { id, count = 1 } = ctx.request.body;\r\n\r\n const products = await strapi\r\n .plugin(\"primershop-product-actions\")\r\n .service(\"productSeries\")\r\n .createProductsFromSeries(id, count);\r\n\r\n return { data: products };\r\n } catch (error) {\r\n ctx.throw(500, error);\r\n }\r\n },\r\n\r\n async updateProducts(ctx: Context) {\r\n try {\r\n const { seriesId, fieldsToUpdate } = ctx.request.body;\r\n\r\n await strapi\r\n .plugin(\"primershop-product-actions\")\r\n .service(\"productSeries\")\r\n .updateSeriesProducts(seriesId, fieldsToUpdate);\r\n\r\n return { success: true };\r\n } catch (error) {\r\n ctx.throw(500, error);\r\n }\r\n },\r\n});\r\nexport default productSeries;\r\n"],"names":["productSeries","strapi","createProducts","ctx","id","count","request","body","products","plugin","service","createProductsFromSeries","data","error","throw","updateProducts","seriesId","fieldsToUpdate","updateSeriesProducts","success"],"mappings":";;AAGA,MAAMA,gBAAgB,CAAC,EACrBC,MAAM,EAGP,IAAuB;AACtB,QAAA,MAAMC,gBAAeC,GAAY,EAAA;YAC/B,IAAI;gBACF,MAAM,EAAEC,EAAE,EAAEC,KAAAA,GAAQ,CAAC,EAAE,GAAGF,GAAAA,CAAIG,OAAO,CAACC,IAAI;gBAE1C,MAAMC,QAAAA,GAAW,MAAMP,MAAAA,CACpBQ,MAAM,CAAC,4BAAA,CAAA,CACPC,OAAO,CAAC,eAAA,CAAA,CACRC,wBAAwB,CAACP,EAAAA,EAAIC,KAAAA,CAAAA;gBAEhC,OAAO;oBAAEO,IAAAA,EAAMJ;AAAS,iBAAA;AAC1B,YAAA,CAAA,CAAE,OAAOK,KAAAA,EAAO;gBACdV,GAAAA,CAAIW,KAAK,CAAC,GAAA,EAAKD,KAAAA,CAAAA;AACjB,YAAA;AACF,QAAA,CAAA;AAEA,QAAA,MAAME,gBAAeZ,GAAY,EAAA;YAC/B,IAAI;gBACF,MAAM,EAAEa,QAAQ,EAAEC,cAAc,EAAE,GAAGd,GAAAA,CAAIG,OAAO,CAACC,IAAI;gBAErD,MAAMN,MAAAA,CACHQ,MAAM,CAAC,4BAAA,CAAA,CACPC,OAAO,CAAC,eAAA,CAAA,CACRQ,oBAAoB,CAACF,QAAAA,EAAUC,cAAAA,CAAAA;gBAElC,OAAO;oBAAEE,OAAAA,EAAS;AAAK,iBAAA;AACzB,YAAA,CAAA,CAAE,OAAON,KAAAA,EAAO;gBACdV,GAAAA,CAAIW,KAAK,CAAC,GAAA,EAAKD,KAAAA,CAAAA;AACjB,YAAA;AACF,QAAA;KACF;;;;"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
const productSeries = ({ strapi })=>({
|
|
2
|
-
async createProducts (ctx) {
|
|
3
|
-
try {
|
|
4
|
-
const { id, count = 1 } = ctx.request.body;
|
|
5
|
-
const products = await strapi.plugin("primershop-product-actions").service("productSeries").createProductsFromSeries(id, count);
|
|
6
|
-
return {
|
|
7
|
-
data: products
|
|
8
|
-
};
|
|
9
|
-
} catch (error) {
|
|
10
|
-
ctx.throw(500, error);
|
|
11
|
-
}
|
|
12
|
-
},
|
|
13
|
-
async updateProducts (ctx) {
|
|
14
|
-
try {
|
|
15
|
-
const { seriesId, fieldsToUpdate } = ctx.request.body;
|
|
16
|
-
await strapi.plugin("primershop-product-actions").service("productSeries").updateSeriesProducts(seriesId, fieldsToUpdate);
|
|
17
|
-
return {
|
|
18
|
-
success: true
|
|
19
|
-
};
|
|
20
|
-
} catch (error) {
|
|
21
|
-
ctx.throw(500, error);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
export { productSeries as default };
|
|
27
|
-
//# sourceMappingURL=product-series.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"product-series.mjs","sources":["../../../server/src/controllers/product-series.ts"],"sourcesContent":["import type { Core } from \"@strapi/strapi\";\r\nimport type { Context } from \"koa\";\r\n\r\nconst productSeries = ({\r\n strapi,\r\n}: {\r\n strapi: Core.Strapi;\r\n}): Core.Controller => ({\r\n async createProducts(ctx: Context) {\r\n try {\r\n const { id, count = 1 } = ctx.request.body;\r\n\r\n const products = await strapi\r\n .plugin(\"primershop-product-actions\")\r\n .service(\"productSeries\")\r\n .createProductsFromSeries(id, count);\r\n\r\n return { data: products };\r\n } catch (error) {\r\n ctx.throw(500, error);\r\n }\r\n },\r\n\r\n async updateProducts(ctx: Context) {\r\n try {\r\n const { seriesId, fieldsToUpdate } = ctx.request.body;\r\n\r\n await strapi\r\n .plugin(\"primershop-product-actions\")\r\n .service(\"productSeries\")\r\n .updateSeriesProducts(seriesId, fieldsToUpdate);\r\n\r\n return { success: true };\r\n } catch (error) {\r\n ctx.throw(500, error);\r\n }\r\n },\r\n});\r\nexport default productSeries;\r\n"],"names":["productSeries","strapi","createProducts","ctx","id","count","request","body","products","plugin","service","createProductsFromSeries","data","error","throw","updateProducts","seriesId","fieldsToUpdate","updateSeriesProducts","success"],"mappings":"AAGA,MAAMA,gBAAgB,CAAC,EACrBC,MAAM,EAGP,IAAuB;AACtB,QAAA,MAAMC,gBAAeC,GAAY,EAAA;YAC/B,IAAI;gBACF,MAAM,EAAEC,EAAE,EAAEC,KAAAA,GAAQ,CAAC,EAAE,GAAGF,GAAAA,CAAIG,OAAO,CAACC,IAAI;gBAE1C,MAAMC,QAAAA,GAAW,MAAMP,MAAAA,CACpBQ,MAAM,CAAC,4BAAA,CAAA,CACPC,OAAO,CAAC,eAAA,CAAA,CACRC,wBAAwB,CAACP,EAAAA,EAAIC,KAAAA,CAAAA;gBAEhC,OAAO;oBAAEO,IAAAA,EAAMJ;AAAS,iBAAA;AAC1B,YAAA,CAAA,CAAE,OAAOK,KAAAA,EAAO;gBACdV,GAAAA,CAAIW,KAAK,CAAC,GAAA,EAAKD,KAAAA,CAAAA;AACjB,YAAA;AACF,QAAA,CAAA;AAEA,QAAA,MAAME,gBAAeZ,GAAY,EAAA;YAC/B,IAAI;gBACF,MAAM,EAAEa,QAAQ,EAAEC,cAAc,EAAE,GAAGd,GAAAA,CAAIG,OAAO,CAACC,IAAI;gBAErD,MAAMN,MAAAA,CACHQ,MAAM,CAAC,4BAAA,CAAA,CACPC,OAAO,CAAC,eAAA,CAAA,CACRQ,oBAAoB,CAACF,QAAAA,EAAUC,cAAAA,CAAAA;gBAElC,OAAO;oBAAEE,OAAAA,EAAS;AAAK,iBAAA;AACzB,YAAA,CAAA,CAAE,OAAON,KAAAA,EAAO;gBACdV,GAAAA,CAAIW,KAAK,CAAC,GAAA,EAAKD,KAAAA,CAAAA;AACjB,YAAA;AACF,QAAA;KACF;;;;"}
|
package/dist/server/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../server/src/index.ts"],"sourcesContent":["import { controllers } from \"./controllers\";\r\nimport { routes } from \"./routes\";\r\nimport { services } from \"./services\";\r\nimport register from \"./register\";\r\nimport bootstrap from \"./bootstrap\";\r\n\r\nexport default {\r\n register,\r\n\r\n controllers,\r\n routes,\r\n services,\r\n middlewares: {},\r\n bootstrap,\r\n };\r\n"],"names":["register","controllers","routes","services","middlewares","bootstrap"],"mappings":";;;;;;;;AAMA,YAAe;AACXA,IAAAA,QAAAA;AAEAC,iBAAAA,mBAAAA;AACAC,YAAAA,cAAAA;AACAC,cAAAA,gBAAAA;AACAC,IAAAA,WAAAA,EAAa,EAAC;AACdC,IAAAA;AACF,CAAA;;;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../../server/src/index.ts"],"sourcesContent":["import { controllers } from \"./controllers\";\r\nimport { routes } from \"./routes\";\r\nimport { services } from \"./services\";\r\nimport register from \"./register\";\r\nimport bootstrap from \"./bootstrap\";\r\n\r\nexport default {\r\n register,\r\n\r\n controllers,\r\n routes,\r\n services,\r\n middlewares: {},\r\n bootstrap,\r\n };\r\n"],"names":["register","controllers","routes","services","middlewares","bootstrap"],"mappings":";;;;;;AAMA,YAAe;AACXA,IAAAA,QAAAA;AAEAC,IAAAA,WAAAA;AACAC,IAAAA,MAAAA;AACAC,IAAAA,QAAAA;AACAC,IAAAA,WAAAA,EAAa,EAAC;AACdC,IAAAA;AACF,CAAA;;;;"}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const permissions = {
|
|
4
|
-
actions: [
|
|
5
|
-
{
|
|
6
|
-
section: "plugins",
|
|
7
|
-
displayName: "Use product actions",
|
|
8
|
-
uid: "use",
|
|
9
|
-
pluginName: "primershop-product-actions"
|
|
10
|
-
},
|
|
11
|
-
{
|
|
12
|
-
section: "plugins",
|
|
13
|
-
displayName: "Create",
|
|
14
|
-
uid: "product-series.create",
|
|
15
|
-
subCategory: "product-series",
|
|
16
|
-
pluginName: "primershop-product-actions"
|
|
17
|
-
},
|
|
18
|
-
{
|
|
19
|
-
section: "plugins",
|
|
20
|
-
displayName: "Read",
|
|
21
|
-
uid: "product-series.read",
|
|
22
|
-
subCategory: "product-series",
|
|
23
|
-
pluginName: "primershop-product-actions",
|
|
24
|
-
aliases: [
|
|
25
|
-
{
|
|
26
|
-
actionId: "plugin::content-manager.explorer.read",
|
|
27
|
-
subjects: [
|
|
28
|
-
"api::product-series.product-series"
|
|
29
|
-
]
|
|
30
|
-
}
|
|
31
|
-
]
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
section: "plugins",
|
|
35
|
-
displayName: "Update",
|
|
36
|
-
uid: "product-series.update",
|
|
37
|
-
subCategory: "product-series",
|
|
38
|
-
pluginName: "primershop-product-actions"
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
section: "plugins",
|
|
42
|
-
displayName: "Delete",
|
|
43
|
-
uid: "product-series.delete",
|
|
44
|
-
subCategory: "product-series",
|
|
45
|
-
pluginName: "primershop-product-actions"
|
|
46
|
-
}
|
|
47
|
-
]
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
exports.permissions = permissions;
|
|
51
|
-
//# sourceMappingURL=permissions.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"permissions.js","sources":["../../server/src/permissions.ts"],"sourcesContent":["export const permissions = {\r\n actions: [\r\n {\r\n section: \"plugins\",\r\n displayName: \"Use product actions\",\r\n uid: \"use\",\r\n pluginName: \"primershop-product-actions\",\r\n },\r\n {\r\n section: \"plugins\",\r\n displayName: \"Create\",\r\n uid: \"product-series.create\",\r\n subCategory: \"product-series\",\r\n pluginName: \"primershop-product-actions\",\r\n },\r\n {\r\n section: \"plugins\",\r\n displayName: \"Read\",\r\n uid: \"product-series.read\",\r\n subCategory: \"product-series\",\r\n pluginName: \"primershop-product-actions\",\r\n aliases: [\r\n {\r\n actionId: \"plugin::content-manager.explorer.read\",\r\n subjects: [\"api::product-series.product-series\"],\r\n },\r\n ],\r\n },\r\n {\r\n section: \"plugins\",\r\n displayName: \"Update\",\r\n uid: \"product-series.update\",\r\n subCategory: \"product-series\",\r\n pluginName: \"primershop-product-actions\",\r\n },\r\n {\r\n section: \"plugins\",\r\n displayName: \"Delete\",\r\n uid: \"product-series.delete\",\r\n subCategory: \"product-series\",\r\n pluginName: \"primershop-product-actions\",\r\n },\r\n ],\r\n};\r\n"],"names":["permissions","actions","section","displayName","uid","pluginName","subCategory","aliases","actionId","subjects"],"mappings":";;MAAaA,WAAAA,GAAc;IACzBC,OAAAA,EAAS;AACP,QAAA;YACEC,OAAAA,EAAS,SAAA;YACTC,WAAAA,EAAa,qBAAA;YACbC,GAAAA,EAAK,KAAA;YACLC,UAAAA,EAAY;AACd,SAAA;AACA,QAAA;YACEH,OAAAA,EAAS,SAAA;YACTC,WAAAA,EAAa,QAAA;YACbC,GAAAA,EAAK,uBAAA;YACLE,WAAAA,EAAa,gBAAA;YACbD,UAAAA,EAAY;AACd,SAAA;AACA,QAAA;YACEH,OAAAA,EAAS,SAAA;YACTC,WAAAA,EAAa,MAAA;YACbC,GAAAA,EAAK,qBAAA;YACLE,WAAAA,EAAa,gBAAA;YACbD,UAAAA,EAAY,4BAAA;YACZE,OAAAA,EAAS;AACP,gBAAA;oBACEC,QAAAA,EAAU,uCAAA;oBACVC,QAAAA,EAAU;AAAC,wBAAA;AAAqC;AAClD;AACD;AACH,SAAA;AACA,QAAA;YACEP,OAAAA,EAAS,SAAA;YACTC,WAAAA,EAAa,QAAA;YACbC,GAAAA,EAAK,uBAAA;YACLE,WAAAA,EAAa,gBAAA;YACbD,UAAAA,EAAY;AACd,SAAA;AACA,QAAA;YACEH,OAAAA,EAAS,SAAA;YACTC,WAAAA,EAAa,QAAA;YACbC,GAAAA,EAAK,uBAAA;YACLE,WAAAA,EAAa,gBAAA;YACbD,UAAAA,EAAY;AACd;AACD;AACH;;;;"}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
const permissions = {
|
|
2
|
-
actions: [
|
|
3
|
-
{
|
|
4
|
-
section: "plugins",
|
|
5
|
-
displayName: "Use product actions",
|
|
6
|
-
uid: "use",
|
|
7
|
-
pluginName: "primershop-product-actions"
|
|
8
|
-
},
|
|
9
|
-
{
|
|
10
|
-
section: "plugins",
|
|
11
|
-
displayName: "Create",
|
|
12
|
-
uid: "product-series.create",
|
|
13
|
-
subCategory: "product-series",
|
|
14
|
-
pluginName: "primershop-product-actions"
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
section: "plugins",
|
|
18
|
-
displayName: "Read",
|
|
19
|
-
uid: "product-series.read",
|
|
20
|
-
subCategory: "product-series",
|
|
21
|
-
pluginName: "primershop-product-actions",
|
|
22
|
-
aliases: [
|
|
23
|
-
{
|
|
24
|
-
actionId: "plugin::content-manager.explorer.read",
|
|
25
|
-
subjects: [
|
|
26
|
-
"api::product-series.product-series"
|
|
27
|
-
]
|
|
28
|
-
}
|
|
29
|
-
]
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
section: "plugins",
|
|
33
|
-
displayName: "Update",
|
|
34
|
-
uid: "product-series.update",
|
|
35
|
-
subCategory: "product-series",
|
|
36
|
-
pluginName: "primershop-product-actions"
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
section: "plugins",
|
|
40
|
-
displayName: "Delete",
|
|
41
|
-
uid: "product-series.delete",
|
|
42
|
-
subCategory: "product-series",
|
|
43
|
-
pluginName: "primershop-product-actions"
|
|
44
|
-
}
|
|
45
|
-
]
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
export { permissions };
|
|
49
|
-
//# sourceMappingURL=permissions.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"permissions.mjs","sources":["../../server/src/permissions.ts"],"sourcesContent":["export const permissions = {\r\n actions: [\r\n {\r\n section: \"plugins\",\r\n displayName: \"Use product actions\",\r\n uid: \"use\",\r\n pluginName: \"primershop-product-actions\",\r\n },\r\n {\r\n section: \"plugins\",\r\n displayName: \"Create\",\r\n uid: \"product-series.create\",\r\n subCategory: \"product-series\",\r\n pluginName: \"primershop-product-actions\",\r\n },\r\n {\r\n section: \"plugins\",\r\n displayName: \"Read\",\r\n uid: \"product-series.read\",\r\n subCategory: \"product-series\",\r\n pluginName: \"primershop-product-actions\",\r\n aliases: [\r\n {\r\n actionId: \"plugin::content-manager.explorer.read\",\r\n subjects: [\"api::product-series.product-series\"],\r\n },\r\n ],\r\n },\r\n {\r\n section: \"plugins\",\r\n displayName: \"Update\",\r\n uid: \"product-series.update\",\r\n subCategory: \"product-series\",\r\n pluginName: \"primershop-product-actions\",\r\n },\r\n {\r\n section: \"plugins\",\r\n displayName: \"Delete\",\r\n uid: \"product-series.delete\",\r\n subCategory: \"product-series\",\r\n pluginName: \"primershop-product-actions\",\r\n },\r\n ],\r\n};\r\n"],"names":["permissions","actions","section","displayName","uid","pluginName","subCategory","aliases","actionId","subjects"],"mappings":"MAAaA,WAAAA,GAAc;IACzBC,OAAAA,EAAS;AACP,QAAA;YACEC,OAAAA,EAAS,SAAA;YACTC,WAAAA,EAAa,qBAAA;YACbC,GAAAA,EAAK,KAAA;YACLC,UAAAA,EAAY;AACd,SAAA;AACA,QAAA;YACEH,OAAAA,EAAS,SAAA;YACTC,WAAAA,EAAa,QAAA;YACbC,GAAAA,EAAK,uBAAA;YACLE,WAAAA,EAAa,gBAAA;YACbD,UAAAA,EAAY;AACd,SAAA;AACA,QAAA;YACEH,OAAAA,EAAS,SAAA;YACTC,WAAAA,EAAa,MAAA;YACbC,GAAAA,EAAK,qBAAA;YACLE,WAAAA,EAAa,gBAAA;YACbD,UAAAA,EAAY,4BAAA;YACZE,OAAAA,EAAS;AACP,gBAAA;oBACEC,QAAAA,EAAU,uCAAA;oBACVC,QAAAA,EAAU;AAAC,wBAAA;AAAqC;AAClD;AACD;AACH,SAAA;AACA,QAAA;YACEP,OAAAA,EAAS,SAAA;YACTC,WAAAA,EAAa,QAAA;YACbC,GAAAA,EAAK,uBAAA;YACLE,WAAAA,EAAa,gBAAA;YACbD,UAAAA,EAAY;AACd,SAAA;AACA,QAAA;YACEH,OAAAA,EAAS,SAAA;YACTC,WAAAA,EAAa,QAAA;YACbC,GAAAA,EAAK,uBAAA;YACLE,WAAAA,EAAa,gBAAA;YACbD,UAAAA,EAAY;AACd;AACD;AACH;;;;"}
|
package/dist/server/register.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"register.js","sources":["../../server/src/register.ts"],"sourcesContent":["import type { Core } from \"@strapi/strapi\";\r\n\r\nconst register = ({ strapi: _strapi }: { strapi: Core.Strapi }): void => {\r\n // Plugin registration (permissions registered in bootstrap only)\r\n void _strapi;\r\n};\r\n\r\nexport default register;"],"names":["register","strapi","_strapi"],"mappings":";;AAEA,MAAMA,QAAAA,GAAW,CAAC,EAAEC,MAAAA,EAAQC,OAAO,EAA2B,GAAA;AAG9D;;;;"}
|
package/dist/server/register.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"register.mjs","sources":["../../server/src/register.ts"],"sourcesContent":["import type { Core } from \"@strapi/strapi\";\r\n\r\nconst register = ({ strapi: _strapi }: { strapi: Core.Strapi }): void => {\r\n // Plugin registration (permissions registered in bootstrap only)\r\n void _strapi;\r\n};\r\n\r\nexport default register;"],"names":["register","strapi","_strapi"],"mappings":"AAEA,MAAMA,QAAAA,GAAW,CAAC,EAAEC,MAAAA,EAAQC,OAAO,EAA2B,GAAA;AAG9D;;;;"}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var admin = {
|
|
4
|
-
type: "admin",
|
|
5
|
-
routes: [
|
|
6
|
-
{
|
|
7
|
-
method: "POST",
|
|
8
|
-
path: "/create-products",
|
|
9
|
-
handler: "productSeries.createProducts",
|
|
10
|
-
config: {
|
|
11
|
-
policies: [
|
|
12
|
-
{
|
|
13
|
-
name: "admin::hasPermissions",
|
|
14
|
-
config: {
|
|
15
|
-
actions: [
|
|
16
|
-
"plugin::primershop-product-actions.product-series.create"
|
|
17
|
-
]
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
]
|
|
21
|
-
}
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
method: "PUT",
|
|
25
|
-
path: "/update-products",
|
|
26
|
-
handler: "productSeries.updateProducts",
|
|
27
|
-
config: {
|
|
28
|
-
policies: [
|
|
29
|
-
{
|
|
30
|
-
name: "admin::hasPermissions",
|
|
31
|
-
config: {
|
|
32
|
-
actions: [
|
|
33
|
-
"plugin::primershop-product-actions.product-series.update"
|
|
34
|
-
]
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
]
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
]
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
module.exports = admin;
|
|
44
|
-
//# sourceMappingURL=admin.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"admin.js","sources":["../../../server/src/routes/admin.ts"],"sourcesContent":["export default {\r\n type: \"admin\",\r\n routes: [\r\n {\r\n method: \"POST\",\r\n path: \"/create-products\",\r\n handler: \"productSeries.createProducts\",\r\n config: {\r\n policies: [\r\n {\r\n name: \"admin::hasPermissions\",\r\n config: {\r\n actions: [\r\n \"plugin::primershop-product-actions.product-series.create\",\r\n ],\r\n },\r\n },\r\n ],\r\n },\r\n },\r\n {\r\n method: \"PUT\",\r\n path: \"/update-products\",\r\n handler: \"productSeries.updateProducts\",\r\n config: {\r\n policies: [\r\n {\r\n name: \"admin::hasPermissions\",\r\n config: {\r\n actions: [\r\n \"plugin::primershop-product-actions.product-series.update\",\r\n ],\r\n },\r\n },\r\n ],\r\n },\r\n },\r\n ],\r\n};\r\n"],"names":["type","routes","method","path","handler","config","policies","name","actions"],"mappings":";;AAAA,YAAe;IACbA,IAAAA,EAAM,OAAA;IACNC,MAAAA,EAAQ;AACN,QAAA;YACEC,MAAAA,EAAQ,MAAA;YACRC,IAAAA,EAAM,kBAAA;YACNC,OAAAA,EAAS,8BAAA;YACTC,MAAAA,EAAQ;gBACNC,QAAAA,EAAU;AACR,oBAAA;wBACEC,IAAAA,EAAM,uBAAA;wBACNF,MAAAA,EAAQ;4BACNG,OAAAA,EAAS;AACP,gCAAA;AACD;AACH;AACF;AACD;AACH;AACF,SAAA;AACA,QAAA;YACEN,MAAAA,EAAQ,KAAA;YACRC,IAAAA,EAAM,kBAAA;YACNC,OAAAA,EAAS,8BAAA;YACTC,MAAAA,EAAQ;gBACNC,QAAAA,EAAU;AACR,oBAAA;wBACEC,IAAAA,EAAM,uBAAA;wBACNF,MAAAA,EAAQ;4BACNG,OAAAA,EAAS;AACP,gCAAA;AACD;AACH;AACF;AACD;AACH;AACF;AACD;AACH,CAAA;;;;"}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
var admin = {
|
|
2
|
-
type: "admin",
|
|
3
|
-
routes: [
|
|
4
|
-
{
|
|
5
|
-
method: "POST",
|
|
6
|
-
path: "/create-products",
|
|
7
|
-
handler: "productSeries.createProducts",
|
|
8
|
-
config: {
|
|
9
|
-
policies: [
|
|
10
|
-
{
|
|
11
|
-
name: "admin::hasPermissions",
|
|
12
|
-
config: {
|
|
13
|
-
actions: [
|
|
14
|
-
"plugin::primershop-product-actions.product-series.create"
|
|
15
|
-
]
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
]
|
|
19
|
-
}
|
|
20
|
-
},
|
|
21
|
-
{
|
|
22
|
-
method: "PUT",
|
|
23
|
-
path: "/update-products",
|
|
24
|
-
handler: "productSeries.updateProducts",
|
|
25
|
-
config: {
|
|
26
|
-
policies: [
|
|
27
|
-
{
|
|
28
|
-
name: "admin::hasPermissions",
|
|
29
|
-
config: {
|
|
30
|
-
actions: [
|
|
31
|
-
"plugin::primershop-product-actions.product-series.update"
|
|
32
|
-
]
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
]
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
]
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
export { admin as default };
|
|
42
|
-
//# sourceMappingURL=admin.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"admin.mjs","sources":["../../../server/src/routes/admin.ts"],"sourcesContent":["export default {\r\n type: \"admin\",\r\n routes: [\r\n {\r\n method: \"POST\",\r\n path: \"/create-products\",\r\n handler: \"productSeries.createProducts\",\r\n config: {\r\n policies: [\r\n {\r\n name: \"admin::hasPermissions\",\r\n config: {\r\n actions: [\r\n \"plugin::primershop-product-actions.product-series.create\",\r\n ],\r\n },\r\n },\r\n ],\r\n },\r\n },\r\n {\r\n method: \"PUT\",\r\n path: \"/update-products\",\r\n handler: \"productSeries.updateProducts\",\r\n config: {\r\n policies: [\r\n {\r\n name: \"admin::hasPermissions\",\r\n config: {\r\n actions: [\r\n \"plugin::primershop-product-actions.product-series.update\",\r\n ],\r\n },\r\n },\r\n ],\r\n },\r\n },\r\n ],\r\n};\r\n"],"names":["type","routes","method","path","handler","config","policies","name","actions"],"mappings":"AAAA,YAAe;IACbA,IAAAA,EAAM,OAAA;IACNC,MAAAA,EAAQ;AACN,QAAA;YACEC,MAAAA,EAAQ,MAAA;YACRC,IAAAA,EAAM,kBAAA;YACNC,OAAAA,EAAS,8BAAA;YACTC,MAAAA,EAAQ;gBACNC,QAAAA,EAAU;AACR,oBAAA;wBACEC,IAAAA,EAAM,uBAAA;wBACNF,MAAAA,EAAQ;4BACNG,OAAAA,EAAS;AACP,gCAAA;AACD;AACH;AACF;AACD;AACH;AACF,SAAA;AACA,QAAA;YACEN,MAAAA,EAAQ,KAAA;YACRC,IAAAA,EAAM,kBAAA;YACNC,OAAAA,EAAS,8BAAA;YACTC,MAAAA,EAAQ;gBACNC,QAAAA,EAAU;AACR,oBAAA;wBACEC,IAAAA,EAAM,uBAAA;wBACNF,MAAAA,EAAQ;4BACNG,OAAAA,EAAS;AACP,gCAAA;AACD;AACH;AACF;AACD;AACH;AACF;AACD;AACH,CAAA;;;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../server/src/routes/index.ts"],"sourcesContent":["import admin from \"./admin\";\r\n\r\nconst routes = { admin };\r\n\r\nexport { routes };\r\n"],"names":["routes","admin"],"mappings":";;;;AAEA,MAAMA,MAAAA,GAAS;AAAEC,IAAAA;AAAM;;;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../../../server/src/routes/index.ts"],"sourcesContent":["import admin from \"./admin\";\r\n\r\nconst routes = { admin };\r\n\r\nexport { routes };\r\n"],"names":["routes","admin"],"mappings":";;AAEA,MAAMA,MAAAA,GAAS;AAAEC,IAAAA;AAAM;;;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../server/src/services/index.ts"],"sourcesContent":["import { productSeriesService } from \"./product-series\";\r\n\r\nexport const services = {\r\n productSeries: productSeriesService,\r\n};\r\n"],"names":["services","productSeries","productSeriesService"],"mappings":";;;;MAEaA,QAAAA,GAAW;IACtBC,aAAAA,EAAeC;AACjB;;;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../../../server/src/services/index.ts"],"sourcesContent":["import { productSeriesService } from \"./product-series\";\r\n\r\nexport const services = {\r\n productSeries: productSeriesService,\r\n};\r\n"],"names":["services","productSeries","productSeriesService"],"mappings":";;MAEaA,QAAAA,GAAW;IACtBC,aAAAA,EAAeC;AACjB;;;;"}
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const productSeriesService = ({ strapi })=>({
|
|
4
|
-
async createProductsFromSeries (seriesId, count = 1) {
|
|
5
|
-
const series = await getSeries(strapi, seriesId);
|
|
6
|
-
const products = [];
|
|
7
|
-
const startIndex = series.products?.length || 0;
|
|
8
|
-
for(let i = 0; i < count; i++){
|
|
9
|
-
const index = startIndex + i;
|
|
10
|
-
// Create product with series data
|
|
11
|
-
const product = await strapi.documents("api::product.product").create({
|
|
12
|
-
data: {
|
|
13
|
-
name: `${series.name} #${index + 1}`,
|
|
14
|
-
slug: `${series.slug}-${index + 1}`,
|
|
15
|
-
series: {
|
|
16
|
-
set: seriesId
|
|
17
|
-
},
|
|
18
|
-
seriesIndex: index,
|
|
19
|
-
category: series.category ? {
|
|
20
|
-
set: series.category.documentId
|
|
21
|
-
} : null,
|
|
22
|
-
creator: series.creator ? {
|
|
23
|
-
set: series.creator?.documentId
|
|
24
|
-
} : null,
|
|
25
|
-
publishedAt: undefined,
|
|
26
|
-
// Copy all required fields from series
|
|
27
|
-
description: series.description,
|
|
28
|
-
shortDescription: series.shortDescription,
|
|
29
|
-
media: series.media,
|
|
30
|
-
coverImage: series.coverImage,
|
|
31
|
-
seo: series.seo,
|
|
32
|
-
totalCost: series.totalCost,
|
|
33
|
-
wholesalePrice: series.wholesalePrice,
|
|
34
|
-
retailPrice: series.retailPrice
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
products.push(product);
|
|
38
|
-
}
|
|
39
|
-
return products;
|
|
40
|
-
},
|
|
41
|
-
async updateSeriesProducts (seriesId, fieldsToUpdate) {
|
|
42
|
-
const series = await getSeries(strapi, seriesId);
|
|
43
|
-
const dataToUpdate = {};
|
|
44
|
-
if (fieldsToUpdate.includes("description")) {
|
|
45
|
-
dataToUpdate.description = series.description;
|
|
46
|
-
}
|
|
47
|
-
if (fieldsToUpdate.includes("shortDescription")) {
|
|
48
|
-
dataToUpdate.shortDescription = series.shortDescription;
|
|
49
|
-
}
|
|
50
|
-
if (fieldsToUpdate.includes("media")) {
|
|
51
|
-
dataToUpdate.media = series.media;
|
|
52
|
-
}
|
|
53
|
-
if (fieldsToUpdate.includes("coverImage")) {
|
|
54
|
-
dataToUpdate.coverImage = series.coverImage;
|
|
55
|
-
}
|
|
56
|
-
if (fieldsToUpdate.includes("seo")) {
|
|
57
|
-
dataToUpdate.seo = series.seo;
|
|
58
|
-
}
|
|
59
|
-
if (fieldsToUpdate.includes("totalCost")) {
|
|
60
|
-
dataToUpdate.totalCost = series.totalCost;
|
|
61
|
-
}
|
|
62
|
-
if (fieldsToUpdate.includes("wholesalePrice")) {
|
|
63
|
-
dataToUpdate.wholesalePrice = series.wholesalePrice;
|
|
64
|
-
}
|
|
65
|
-
if (fieldsToUpdate.includes("retailPrice")) {
|
|
66
|
-
dataToUpdate.retailPrice = series.retailPrice;
|
|
67
|
-
}
|
|
68
|
-
if (fieldsToUpdate.includes("category")) {
|
|
69
|
-
dataToUpdate.category = {
|
|
70
|
-
set: [
|
|
71
|
-
series.category?.documentId
|
|
72
|
-
]
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
if (fieldsToUpdate.includes("creator")) {
|
|
76
|
-
dataToUpdate.creator = {
|
|
77
|
-
set: [
|
|
78
|
-
series.creator?.documentId
|
|
79
|
-
]
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
const updatePromises = series.products?.map((product)=>strapi.documents("api::product.product").update({
|
|
83
|
-
documentId: product.documentId,
|
|
84
|
-
data: {
|
|
85
|
-
...dataToUpdate
|
|
86
|
-
}
|
|
87
|
-
}));
|
|
88
|
-
if (updatePromises) {
|
|
89
|
-
await Promise.all(updatePromises);
|
|
90
|
-
}
|
|
91
|
-
return true;
|
|
92
|
-
}
|
|
93
|
-
});
|
|
94
|
-
async function getSeries(strapi, seriesId) {
|
|
95
|
-
const series = await strapi.documents("api::product-series.product-series").findOne({
|
|
96
|
-
documentId: seriesId,
|
|
97
|
-
populate: [
|
|
98
|
-
"products",
|
|
99
|
-
"category",
|
|
100
|
-
"creator",
|
|
101
|
-
"media",
|
|
102
|
-
"coverImage",
|
|
103
|
-
"seo"
|
|
104
|
-
]
|
|
105
|
-
});
|
|
106
|
-
if (!series) {
|
|
107
|
-
throw new Error("Series not found");
|
|
108
|
-
}
|
|
109
|
-
return series;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
exports.productSeriesService = productSeriesService;
|
|
113
|
-
//# sourceMappingURL=product-series.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"product-series.js","sources":["../../../server/src/services/product-series.ts"],"sourcesContent":["import type { Core } from \"@strapi/strapi\";\r\n\r\ninterface Series {\r\n name: string;\r\n slug: string;\r\n products?: Array<{ documentId: string }>;\r\n category?: { documentId: string };\r\n creator?: { documentId: string };\r\n description: unknown;\r\n shortDescription: string;\r\n media: unknown;\r\n coverImage: unknown;\r\n seo: unknown;\r\n totalCost: number;\r\n wholesalePrice: number;\r\n retailPrice: number;\r\n}\r\n\r\ninterface ProductData {\r\n name: string;\r\n slug: string;\r\n series: { set: string };\r\n seriesIndex: number;\r\n category: { set: string };\r\n creator: { set: string };\r\n publishedAt: undefined;\r\n description: unknown;\r\n shortDescription: string;\r\n media: unknown;\r\n coverImage: unknown;\r\n seo: unknown;\r\n totalCost: number;\r\n wholesalePrice: number;\r\n retailPrice: number;\r\n}\r\n\r\nexport const productSeriesService = ({ strapi }: { strapi: Core.Strapi }) => ({\r\n async createProductsFromSeries(seriesId: string, count = 1) {\r\n const series = await getSeries(strapi, seriesId);\r\n\r\n const products: unknown[] = [];\r\n const startIndex = series.products?.length || 0;\r\n\r\n for (let i = 0; i < count; i++) {\r\n const index = startIndex + i;\r\n\r\n // Create product with series data\r\n const product = await strapi.documents(\"api::product.product\").create({\r\n data: {\r\n name: `${series.name} #${index + 1}`,\r\n slug: `${series.slug}-${index + 1}`,\r\n series: {\r\n set: seriesId,\r\n },\r\n seriesIndex: index,\r\n category: series.category\r\n ? {\r\n set: series.category.documentId,\r\n }\r\n : null,\r\n creator: series.creator\r\n ? {\r\n set: series.creator?.documentId,\r\n }\r\n : null,\r\n publishedAt: undefined,\r\n // Copy all required fields from series\r\n description: series.description,\r\n shortDescription: series.shortDescription,\r\n media: series.media,\r\n coverImage: series.coverImage,\r\n seo: series.seo,\r\n totalCost: series.totalCost,\r\n wholesalePrice: series.wholesalePrice,\r\n retailPrice: series.retailPrice,\r\n } as ProductData,\r\n });\r\n products.push(product);\r\n }\r\n\r\n return products;\r\n },\r\n\r\n async updateSeriesProducts(seriesId: string, fieldsToUpdate: string[]) {\r\n const series = await getSeries(strapi, seriesId);\r\n\r\n const dataToUpdate: Record<string, unknown> = {};\r\n\r\n if (fieldsToUpdate.includes(\"description\")) {\r\n dataToUpdate.description = series.description;\r\n }\r\n\r\n if (fieldsToUpdate.includes(\"shortDescription\")) {\r\n dataToUpdate.shortDescription = series.shortDescription;\r\n }\r\n\r\n if (fieldsToUpdate.includes(\"media\")) {\r\n dataToUpdate.media = series.media;\r\n }\r\n\r\n if (fieldsToUpdate.includes(\"coverImage\")) {\r\n dataToUpdate.coverImage = series.coverImage;\r\n }\r\n\r\n if (fieldsToUpdate.includes(\"seo\")) {\r\n dataToUpdate.seo = series.seo;\r\n }\r\n\r\n if (fieldsToUpdate.includes(\"totalCost\")) {\r\n dataToUpdate.totalCost = series.totalCost;\r\n }\r\n\r\n if (fieldsToUpdate.includes(\"wholesalePrice\")) {\r\n dataToUpdate.wholesalePrice = series.wholesalePrice;\r\n }\r\n\r\n if (fieldsToUpdate.includes(\"retailPrice\")) {\r\n dataToUpdate.retailPrice = series.retailPrice;\r\n }\r\n\r\n if (fieldsToUpdate.includes(\"category\")) {\r\n dataToUpdate.category = {\r\n set: [series.category?.documentId],\r\n };\r\n }\r\n\r\n if (fieldsToUpdate.includes(\"creator\")) {\r\n dataToUpdate.creator = {\r\n set: [series.creator?.documentId],\r\n };\r\n }\r\n\r\n const updatePromises = series.products?.map((product) =>\r\n strapi.documents(\"api::product.product\").update({\r\n documentId: product.documentId,\r\n data: {\r\n ...dataToUpdate,\r\n },\r\n }),\r\n );\r\n\r\n if (updatePromises) {\r\n await Promise.all(updatePromises);\r\n }\r\n return true;\r\n },\r\n});\r\n\r\nasync function getSeries(\r\n strapi: Core.Strapi,\r\n seriesId: string,\r\n): Promise<Series> {\r\n const series = await strapi\r\n .documents(\"api::product-series.product-series\")\r\n .findOne({\r\n documentId: seriesId,\r\n populate: [\r\n \"products\",\r\n \"category\",\r\n \"creator\",\r\n \"media\",\r\n \"coverImage\",\r\n \"seo\",\r\n ],\r\n });\r\n\r\n if (!series) {\r\n throw new Error(\"Series not found\");\r\n }\r\n return series as unknown as Series;\r\n}\r\n"],"names":["productSeriesService","strapi","createProductsFromSeries","seriesId","count","series","getSeries","products","startIndex","length","i","index","product","documents","create","data","name","slug","set","seriesIndex","category","documentId","creator","publishedAt","undefined","description","shortDescription","media","coverImage","seo","totalCost","wholesalePrice","retailPrice","push","updateSeriesProducts","fieldsToUpdate","dataToUpdate","includes","updatePromises","map","update","Promise","all","findOne","populate","Error"],"mappings":";;MAoCaA,oBAAAA,GAAuB,CAAC,EAAEC,MAAM,EAA2B,IAAM;AAC5E,QAAA,MAAMC,wBAAAA,CAAAA,CAAyBC,QAAgB,EAAEC,KAAAA,GAAQ,CAAC,EAAA;YACxD,MAAMC,MAAAA,GAAS,MAAMC,SAAAA,CAAUL,MAAAA,EAAQE,QAAAA,CAAAA;AAEvC,YAAA,MAAMI,WAAsB,EAAE;AAC9B,YAAA,MAAMC,UAAAA,GAAaH,MAAAA,CAAOE,QAAQ,EAAEE,MAAAA,IAAU,CAAA;AAE9C,YA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