@webbycrown/webbycommerce 1.0.2 → 1.1.0

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/README.md CHANGED
@@ -580,6 +580,9 @@ Authorization: Bearer YOUR_JWT_TOKEN
580
580
 
581
581
  ## 📜 Changelog
582
582
 
583
+ ## [1.1.0]
584
+ - ✨ Added Bulk Product API for mass product creation
585
+
583
586
  ## [1.0.2] – Patch Release
584
587
 
585
588
  ### Fixed
@@ -3,7 +3,7 @@ import * as React from "react";
3
3
  import React__default, { useContext, useRef, useCallback, useDebugValue, useMemo, useState, useEffect, useLayoutEffect, createContext as createContext$1, createElement, useReducer } from "react";
4
4
  import { useIntl, FormattedMessage } from "react-intl";
5
5
  import { Flex, Box, Popover, Typography, Button, LinkButton, Link as Link$1, Portal, Alert, Field, SubNav, Badge, TextInput, Pagination, PreviousLink, Dots, PageLink, NextLink, Modal, Main } from "@strapi/design-system";
6
- import { P as PLUGIN_ID } from "./index-Cgnv1DYN.mjs";
6
+ import { P as PLUGIN_ID } from "./index-DIGoLhGE.mjs";
7
7
  import { WarningCircle, CaretDown, Trash } from "@strapi/icons";
8
8
  import "react-dom/client";
9
9
  import ReactDOM, { unstable_batchedUpdates as unstable_batchedUpdates$1 } from "react-dom";
@@ -10289,7 +10289,7 @@ var objectInspect = function inspect_(obj, options, depth, seen) {
10289
10289
  var ys = arrObjKeys(obj, inspect2);
10290
10290
  var isPlainObject2 = gPO ? gPO(obj) === Object.prototype : obj instanceof Object || obj.constructor === Object;
10291
10291
  var protoTag = obj instanceof Object ? "" : "null prototype";
10292
- var stringTag2 = !isPlainObject2 && toStringTag$1 && Object(obj) === obj && toStringTag$1 in obj ? $slice.call(toStr$1(obj), 8, -1) : protoTag ? "Object" : "";
10292
+ var stringTag2 = !isPlainObject2 && toStringTag$1 && Object(obj) === obj && toStringTag$1 in obj ? $slice.call(toStr(obj), 8, -1) : protoTag ? "Object" : "";
10293
10293
  var constructorTag = isPlainObject2 || typeof obj.constructor !== "function" ? "" : obj.constructor.name ? obj.constructor.name + " " : "";
10294
10294
  var tag = constructorTag + (stringTag2 || protoTag ? "[" + $join.call($concat$1.call([], stringTag2 || [], protoTag || []), ": ") + "] " : "");
10295
10295
  if (ys.length === 0) {
@@ -10314,25 +10314,25 @@ function canTrustToString(obj) {
10314
10314
  return !toStringTag$1 || !(typeof obj === "object" && (toStringTag$1 in obj || typeof obj[toStringTag$1] !== "undefined"));
10315
10315
  }
10316
10316
  function isArray$4(obj) {
10317
- return toStr$1(obj) === "[object Array]" && canTrustToString(obj);
10317
+ return toStr(obj) === "[object Array]" && canTrustToString(obj);
10318
10318
  }
10319
10319
  function isDate$2(obj) {
10320
- return toStr$1(obj) === "[object Date]" && canTrustToString(obj);
10320
+ return toStr(obj) === "[object Date]" && canTrustToString(obj);
10321
10321
  }
10322
10322
  function isRegExp$2(obj) {
10323
- return toStr$1(obj) === "[object RegExp]" && canTrustToString(obj);
10323
+ return toStr(obj) === "[object RegExp]" && canTrustToString(obj);
10324
10324
  }
10325
10325
  function isError(obj) {
10326
- return toStr$1(obj) === "[object Error]" && canTrustToString(obj);
10326
+ return toStr(obj) === "[object Error]" && canTrustToString(obj);
10327
10327
  }
10328
10328
  function isString$1(obj) {
10329
- return toStr$1(obj) === "[object String]" && canTrustToString(obj);
10329
+ return toStr(obj) === "[object String]" && canTrustToString(obj);
10330
10330
  }
10331
10331
  function isNumber$1(obj) {
10332
- return toStr$1(obj) === "[object Number]" && canTrustToString(obj);
10332
+ return toStr(obj) === "[object Number]" && canTrustToString(obj);
10333
10333
  }
10334
10334
  function isBoolean$1(obj) {
10335
- return toStr$1(obj) === "[object Boolean]" && canTrustToString(obj);
10335
+ return toStr(obj) === "[object Boolean]" && canTrustToString(obj);
10336
10336
  }
10337
10337
  function isSymbol(obj) {
10338
10338
  if (hasShammedSymbols) {
@@ -10368,7 +10368,7 @@ var hasOwn$1 = Object.prototype.hasOwnProperty || function(key) {
10368
10368
  function has$5(obj, key) {
10369
10369
  return hasOwn$1.call(obj, key);
10370
10370
  }
10371
- function toStr$1(obj) {
10371
+ function toStr(obj) {
10372
10372
  return objectToString.call(obj);
10373
10373
  }
10374
10374
  function nameOf(f2) {
@@ -10677,7 +10677,7 @@ var syntax = SyntaxError;
10677
10677
  var uri = URIError;
10678
10678
  var abs$1 = Math.abs;
10679
10679
  var floor$1 = Math.floor;
10680
- var max$2 = Math.max;
10680
+ var max$1 = Math.max;
10681
10681
  var min$1 = Math.min;
10682
10682
  var pow$1 = Math.pow;
10683
10683
  var round$1 = Math.round;
@@ -10806,78 +10806,99 @@ function requireObject_getPrototypeOf() {
10806
10806
  Object_getPrototypeOf = $Object2.getPrototypeOf || null;
10807
10807
  return Object_getPrototypeOf;
10808
10808
  }
10809
- var ERROR_MESSAGE = "Function.prototype.bind called on incompatible ";
10810
- var toStr = Object.prototype.toString;
10811
- var max$1 = Math.max;
10812
- var funcType = "[object Function]";
10813
- var concatty = function concatty2(a2, b2) {
10814
- var arr = [];
10815
- for (var i2 = 0; i2 < a2.length; i2 += 1) {
10816
- arr[i2] = a2[i2];
10817
- }
10818
- for (var j2 = 0; j2 < b2.length; j2 += 1) {
10819
- arr[j2 + a2.length] = b2[j2];
10820
- }
10821
- return arr;
10822
- };
10823
- var slicy = function slicy2(arrLike, offset) {
10824
- var arr = [];
10825
- for (var i2 = offset, j2 = 0; i2 < arrLike.length; i2 += 1, j2 += 1) {
10826
- arr[j2] = arrLike[i2];
10827
- }
10828
- return arr;
10829
- };
10830
- var joiny = function(arr, joiner) {
10831
- var str = "";
10832
- for (var i2 = 0; i2 < arr.length; i2 += 1) {
10833
- str += arr[i2];
10834
- if (i2 + 1 < arr.length) {
10835
- str += joiner;
10809
+ var implementation;
10810
+ var hasRequiredImplementation;
10811
+ function requireImplementation() {
10812
+ if (hasRequiredImplementation) return implementation;
10813
+ hasRequiredImplementation = 1;
10814
+ var ERROR_MESSAGE = "Function.prototype.bind called on incompatible ";
10815
+ var toStr2 = Object.prototype.toString;
10816
+ var max2 = Math.max;
10817
+ var funcType = "[object Function]";
10818
+ var concatty = function concatty2(a2, b2) {
10819
+ var arr = [];
10820
+ for (var i2 = 0; i2 < a2.length; i2 += 1) {
10821
+ arr[i2] = a2[i2];
10836
10822
  }
10837
- }
10838
- return str;
10839
- };
10840
- var implementation$1 = function bind(that) {
10841
- var target = this;
10842
- if (typeof target !== "function" || toStr.apply(target) !== funcType) {
10843
- throw new TypeError(ERROR_MESSAGE + target);
10844
- }
10845
- var args = slicy(arguments, 1);
10846
- var bound;
10847
- var binder = function() {
10848
- if (this instanceof bound) {
10849
- var result = target.apply(
10850
- this,
10851
- concatty(args, arguments)
10852
- );
10853
- if (Object(result) === result) {
10854
- return result;
10823
+ for (var j2 = 0; j2 < b2.length; j2 += 1) {
10824
+ arr[j2 + a2.length] = b2[j2];
10825
+ }
10826
+ return arr;
10827
+ };
10828
+ var slicy = function slicy2(arrLike, offset) {
10829
+ var arr = [];
10830
+ for (var i2 = offset, j2 = 0; i2 < arrLike.length; i2 += 1, j2 += 1) {
10831
+ arr[j2] = arrLike[i2];
10832
+ }
10833
+ return arr;
10834
+ };
10835
+ var joiny = function(arr, joiner) {
10836
+ var str = "";
10837
+ for (var i2 = 0; i2 < arr.length; i2 += 1) {
10838
+ str += arr[i2];
10839
+ if (i2 + 1 < arr.length) {
10840
+ str += joiner;
10855
10841
  }
10856
- return this;
10857
10842
  }
10858
- return target.apply(
10859
- that,
10860
- concatty(args, arguments)
10861
- );
10843
+ return str;
10862
10844
  };
10863
- var boundLength = max$1(0, target.length - args.length);
10864
- var boundArgs = [];
10865
- for (var i2 = 0; i2 < boundLength; i2++) {
10866
- boundArgs[i2] = "$" + i2;
10867
- }
10868
- bound = Function("binder", "return function (" + joiny(boundArgs, ",") + "){ return binder.apply(this,arguments); }")(binder);
10869
- if (target.prototype) {
10870
- var Empty = function Empty2() {
10845
+ implementation = function bind2(that) {
10846
+ var target = this;
10847
+ if (typeof target !== "function" || toStr2.apply(target) !== funcType) {
10848
+ throw new TypeError(ERROR_MESSAGE + target);
10849
+ }
10850
+ var args = slicy(arguments, 1);
10851
+ var bound;
10852
+ var binder = function() {
10853
+ if (this instanceof bound) {
10854
+ var result = target.apply(
10855
+ this,
10856
+ concatty(args, arguments)
10857
+ );
10858
+ if (Object(result) === result) {
10859
+ return result;
10860
+ }
10861
+ return this;
10862
+ }
10863
+ return target.apply(
10864
+ that,
10865
+ concatty(args, arguments)
10866
+ );
10871
10867
  };
10872
- Empty.prototype = target.prototype;
10873
- bound.prototype = new Empty();
10874
- Empty.prototype = null;
10875
- }
10876
- return bound;
10877
- };
10878
- var implementation = implementation$1;
10879
- var functionBind = Function.prototype.bind || implementation;
10880
- var functionCall = Function.prototype.call;
10868
+ var boundLength = max2(0, target.length - args.length);
10869
+ var boundArgs = [];
10870
+ for (var i2 = 0; i2 < boundLength; i2++) {
10871
+ boundArgs[i2] = "$" + i2;
10872
+ }
10873
+ bound = Function("binder", "return function (" + joiny(boundArgs, ",") + "){ return binder.apply(this,arguments); }")(binder);
10874
+ if (target.prototype) {
10875
+ var Empty = function Empty2() {
10876
+ };
10877
+ Empty.prototype = target.prototype;
10878
+ bound.prototype = new Empty();
10879
+ Empty.prototype = null;
10880
+ }
10881
+ return bound;
10882
+ };
10883
+ return implementation;
10884
+ }
10885
+ var functionBind;
10886
+ var hasRequiredFunctionBind;
10887
+ function requireFunctionBind() {
10888
+ if (hasRequiredFunctionBind) return functionBind;
10889
+ hasRequiredFunctionBind = 1;
10890
+ var implementation2 = requireImplementation();
10891
+ functionBind = Function.prototype.bind || implementation2;
10892
+ return functionBind;
10893
+ }
10894
+ var functionCall;
10895
+ var hasRequiredFunctionCall;
10896
+ function requireFunctionCall() {
10897
+ if (hasRequiredFunctionCall) return functionCall;
10898
+ hasRequiredFunctionCall = 1;
10899
+ functionCall = Function.prototype.call;
10900
+ return functionCall;
10901
+ }
10881
10902
  var functionApply;
10882
10903
  var hasRequiredFunctionApply;
10883
10904
  function requireFunctionApply() {
@@ -10887,14 +10908,14 @@ function requireFunctionApply() {
10887
10908
  return functionApply;
10888
10909
  }
10889
10910
  var reflectApply = typeof Reflect !== "undefined" && Reflect && Reflect.apply;
10890
- var bind$3 = functionBind;
10911
+ var bind$3 = requireFunctionBind();
10891
10912
  var $apply$1 = requireFunctionApply();
10892
- var $call$2 = functionCall;
10913
+ var $call$2 = requireFunctionCall();
10893
10914
  var $reflectApply = reflectApply;
10894
10915
  var actualApply = $reflectApply || bind$3.call($call$2, $apply$1);
10895
- var bind$2 = functionBind;
10916
+ var bind$2 = requireFunctionBind();
10896
10917
  var $TypeError$4 = type;
10897
- var $call$1 = functionCall;
10918
+ var $call$1 = requireFunctionCall();
10898
10919
  var $actualApply = actualApply;
10899
10920
  var callBindApplyHelpers = function callBindBasic(args) {
10900
10921
  if (args.length < 1 || typeof args[0] !== "function") {
@@ -10960,8 +10981,8 @@ function requireHasown() {
10960
10981
  hasRequiredHasown = 1;
10961
10982
  var call = Function.prototype.call;
10962
10983
  var $hasOwn = Object.prototype.hasOwnProperty;
10963
- var bind3 = functionBind;
10964
- hasown = bind3.call(call, $hasOwn);
10984
+ var bind2 = requireFunctionBind();
10985
+ hasown = bind2.call(call, $hasOwn);
10965
10986
  return hasown;
10966
10987
  }
10967
10988
  var undefined$1;
@@ -10975,7 +10996,7 @@ var $TypeError$3 = type;
10975
10996
  var $URIError = uri;
10976
10997
  var abs = abs$1;
10977
10998
  var floor = floor$1;
10978
- var max = max$2;
10999
+ var max = max$1;
10979
11000
  var min = min$1;
10980
11001
  var pow = pow$1;
10981
11002
  var round = round$1;
@@ -11009,7 +11030,7 @@ var getProto = requireGetProto();
11009
11030
  var $ObjectGPO = requireObject_getPrototypeOf();
11010
11031
  var $ReflectGPO = requireReflect_getPrototypeOf();
11011
11032
  var $apply = requireFunctionApply();
11012
- var $call = functionCall;
11033
+ var $call = requireFunctionCall();
11013
11034
  var needsEval = {};
11014
11035
  var TypedArray = typeof Uint8Array === "undefined" || !getProto ? undefined$1 : getProto(Uint8Array);
11015
11036
  var INTRINSICS = {
@@ -11180,7 +11201,7 @@ var LEGACY_ALIASES = {
11180
11201
  "%WeakMapPrototype%": ["WeakMap", "prototype"],
11181
11202
  "%WeakSetPrototype%": ["WeakSet", "prototype"]
11182
11203
  };
11183
- var bind$1 = functionBind;
11204
+ var bind$1 = requireFunctionBind();
11184
11205
  var hasOwn = requireHasown();
11185
11206
  var $concat = bind$1.call($call, Array.prototype.concat);
11186
11207
  var $spliceApply = bind$1.call($apply, Array.prototype.splice);
@@ -15511,7 +15532,7 @@ const admin = adminApi.enhanceEndpoints({
15511
15532
  overrideExisting: false
15512
15533
  });
15513
15534
  const { useInitQuery, useTelemetryPropertiesQuery, useInformationQuery, useProjectSettingsQuery, useUpdateProjectSettingsMutation, useGetPluginsQuery, useGetLicenseLimitsQuery, useGetLicenseTrialTimeLeftQuery, useGetGuidedTourMetaQuery } = admin;
15514
- function bind2(fn2, thisArg) {
15535
+ function bind(fn2, thisArg) {
15515
15536
  return function wrap() {
15516
15537
  return fn2.apply(thisArg, arguments);
15517
15538
  };
@@ -15648,7 +15669,7 @@ function merge2() {
15648
15669
  const extend = (a2, b2, thisArg, { allOwnKeys } = {}) => {
15649
15670
  forEach$1(b2, (val, key) => {
15650
15671
  if (thisArg && isFunction$1(val)) {
15651
- a2[key] = bind2(val, thisArg);
15672
+ a2[key] = bind(val, thisArg);
15652
15673
  } else {
15653
15674
  a2[key] = val;
15654
15675
  }
@@ -17928,7 +17949,7 @@ Object.entries(HttpStatusCode$1).forEach(([key, value]) => {
17928
17949
  });
17929
17950
  function createInstance(defaultConfig) {
17930
17951
  const context = new Axios$1(defaultConfig);
17931
- const instance = bind2(Axios$1.prototype.request, context);
17952
+ const instance = bind(Axios$1.prototype.request, context);
17932
17953
  utils$1.extend(instance, Axios$1.prototype, context, { allOwnKeys: true });
17933
17954
  utils$1.extend(instance, context, null, { allOwnKeys: true });
17934
17955
  instance.create = function create2(instanceConfig) {
@@ -27043,6 +27064,115 @@ const ApiCollectionsContent = () => {
27043
27064
  "dimensions": {"length": 10, "width": 5, "height": 2},
27044
27065
  "product_categories": [1, 2],
27045
27066
  "tags": [1]
27067
+ }`
27068
+ },
27069
+ {
27070
+ id: "create-bulk-products",
27071
+ method: "POST",
27072
+ path: getApiPath("/api/webbycommerce/products/bulk"),
27073
+ title: formatMessage({
27074
+ id: `${PLUGIN_ID}.settings.apiCollections.products.createBulk.title`,
27075
+ defaultMessage: "Create Products in Bulk"
27076
+ }),
27077
+ summary: formatMessage({
27078
+ id: `${PLUGIN_ID}.settings.apiCollections.products.createBulk.summary`,
27079
+ defaultMessage: "Create multiple products in a single request. Returns detailed results for each product including success and failure status."
27080
+ }),
27081
+ auth: formatMessage({
27082
+ id: `${PLUGIN_ID}.settings.apiCollections.products.authAdmin`,
27083
+ defaultMessage: "Auth: requires JWT token (Authorization: Bearer <token>) and administrator role."
27084
+ }),
27085
+ response: `{
27086
+ "data": {
27087
+ "success": [
27088
+ {
27089
+ "index": 0,
27090
+ "product": {
27091
+ "id": 1,
27092
+ "name": "Product 1",
27093
+ "price": 49.99,
27094
+ "sku": "P001",
27095
+ "createdAt": "2024-01-01T00:00:00.000Z"
27096
+ }
27097
+ }
27098
+ ],
27099
+ "failed": [
27100
+ {
27101
+ "index": 1,
27102
+ "product": {
27103
+ "name": "Product 2",
27104
+ "price": "invalid"
27105
+ },
27106
+ "errors": ["Price must be a valid positive number."]
27107
+ }
27108
+ ],
27109
+ "summary": {
27110
+ "total": 2,
27111
+ "successful": 1,
27112
+ "failed": 1
27113
+ }
27114
+ }
27115
+ }`,
27116
+ usage: [
27117
+ "Include the JWT token in the Authorization header.",
27118
+ "Send an array of products in the request body.",
27119
+ "Each product must have name and price (same validation as single product creation).",
27120
+ "Maximum 100 products per request.",
27121
+ "Returns 200 if all succeed, 207 if mixed results, 400 if all fail.",
27122
+ "Check the summary and failed arrays to see which products succeeded or failed."
27123
+ ],
27124
+ getCurl: () => `curl -X POST http://localhost:1337${getApiPath("/api/webbycommerce/products/bulk")} \\
27125
+ -H "Authorization: Bearer YOUR_JWT_TOKEN" \\
27126
+ -H "Content-Type: application/json" \\
27127
+ -d '{
27128
+ "products": [
27129
+ {
27130
+ "name": "Product 1",
27131
+ "price": 49.99,
27132
+ "description": "First product",
27133
+ "sku": "P001",
27134
+ "stock_quantity": 50
27135
+ },
27136
+ {
27137
+ "name": "Product 2",
27138
+ "price": 29.99,
27139
+ "description": "Second product",
27140
+ "sku": "P002",
27141
+ "stock_quantity": 30
27142
+ }
27143
+ ]
27144
+ }'`,
27145
+ requestBody: `{
27146
+ "products": [
27147
+ {
27148
+ "name": "Product 1",
27149
+ "description": "First product description",
27150
+ "price": 49.99,
27151
+ "sale_price": 39.99,
27152
+ "sku": "P001",
27153
+ "slug": "product-1",
27154
+ "stock_quantity": 50,
27155
+ "stock_status": "in_stock",
27156
+ "weight": 1.5,
27157
+ "dimensions": {"length": 10, "width": 5, "height": 2},
27158
+ "product_categories": [1, 2],
27159
+ "tags": [1],
27160
+ "images": [1, 2]
27161
+ },
27162
+ {
27163
+ "name": "Product 2",
27164
+ "description": "Second product description",
27165
+ "price": 29.99,
27166
+ "sale_price": 24.99,
27167
+ "sku": "P002",
27168
+ "slug": "product-2",
27169
+ "stock_quantity": 30,
27170
+ "stock_status": "in_stock",
27171
+ "weight": 0.8,
27172
+ "product_categories": [1],
27173
+ "tags": [2]
27174
+ }
27175
+ ]
27046
27176
  }`
27047
27177
  },
27048
27178
  {