@scryme/sdk 10.1.40 → 10.1.42

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/index.js CHANGED
@@ -2482,6 +2482,72 @@ var UpdateStrapiConnectionDtoSyncDirection = {
2482
2482
  BIDIRECTIONAL: "BIDIRECTIONAL"
2483
2483
  };
2484
2484
 
2485
+ // src/proxy.ts
2486
+ function getEnvOrgSlug() {
2487
+ if (typeof process !== "undefined" && process.env) {
2488
+ const slug = process.env.SCRYME_ORG_SLUG || process.env.NEXT_PUBLIC_SCRYME_ORG_SLUG;
2489
+ if (slug) return slug;
2490
+ }
2491
+ try {
2492
+ const getMeta = new Function("return typeof import.meta !== 'undefined' ? import.meta : undefined");
2493
+ const meta = getMeta();
2494
+ if (meta && meta.env) {
2495
+ const slug = meta.env.VITE_SCRYME_ORG_SLUG || meta.env.SCRYME_ORG_SLUG;
2496
+ if (slug) return slug;
2497
+ }
2498
+ } catch (e) {
2499
+ }
2500
+ return void 0;
2501
+ }
2502
+ function expectsOrgSlug(fn) {
2503
+ const fnStr = fn.toString();
2504
+ const match = fnStr.match(/^\s*(?:async\s+)?\(([^)]+)\)/);
2505
+ if (!match) {
2506
+ const singleMatch = fnStr.match(/^\s*(\w+)\s*=>/);
2507
+ return singleMatch ? singleMatch[1] === "orgSlug" : false;
2508
+ }
2509
+ const firstParam = match[1].split(",")[0].split(":")[0].trim();
2510
+ return firstParam === "orgSlug";
2511
+ }
2512
+ function getStringParamCount(fn) {
2513
+ const fnStr = fn.toString();
2514
+ const match = fnStr.match(/^\s*(?:async\s+)?\(([^)]+)\)/);
2515
+ if (!match) return 0;
2516
+ const params = match[1].split(",").map((p) => p.trim());
2517
+ let count = 0;
2518
+ for (const param of params) {
2519
+ const cleanParam = param.split(":")[0].split("=")[0].trim();
2520
+ const lower = cleanParam.toLowerCase();
2521
+ if (lower === "params" || lower === "options" || lower.endsWith("dto") || lower.endsWith("body") || lower.endsWith("payload")) {
2522
+ break;
2523
+ }
2524
+ count++;
2525
+ }
2526
+ return count;
2527
+ }
2528
+ var getScrymeV3API2 = (axiosInstance, defaultOrgSlug) => {
2529
+ const api = getScrymeV3API(axiosInstance);
2530
+ return new Proxy(api, {
2531
+ get(target, prop, receiver) {
2532
+ const originalValue = Reflect.get(target, prop, receiver);
2533
+ if (typeof originalValue === "function") {
2534
+ if (expectsOrgSlug(originalValue)) {
2535
+ return function(...args) {
2536
+ const stringParamsExpected = getStringParamCount(originalValue);
2537
+ const stringArgsPassed = args.filter((arg) => typeof arg === "string").length;
2538
+ if (stringArgsPassed < stringParamsExpected) {
2539
+ const envSlug = defaultOrgSlug || getEnvOrgSlug() || "default-org";
2540
+ return originalValue.apply(this, [envSlug, ...args]);
2541
+ }
2542
+ return originalValue.apply(this, args);
2543
+ };
2544
+ }
2545
+ }
2546
+ return originalValue;
2547
+ }
2548
+ });
2549
+ };
2550
+
2485
2551
  // src/base.ts
2486
2552
  var methodsWithOrgSlugSet = /* @__PURE__ */ new Set([
2487
2553
  "publicServicesListServices",
@@ -2732,6 +2798,9 @@ var ordersMapping = {
2732
2798
  updateStatus: "ordersUpdateStatus",
2733
2799
  requestB2BQuote: "ordersRequestB2BQuote",
2734
2800
  convertQuoteToOrder: "ordersConvertQuoteToOrder",
2801
+ getCatalog: "b2BGetCatalog",
2802
+ getInvoices: "b2BGetInvoices",
2803
+ createQuote: "b2BCreateQuote",
2735
2804
  getB2BCatalog: "b2BGetCatalog",
2736
2805
  getB2BInvoices: "b2BGetInvoices",
2737
2806
  getB2BOrders: "b2BGetOrders",
@@ -3284,6 +3353,7 @@ var ScrymeClientSDK = class {
3284
3353
  };
3285
3354
  this.inventory = buildModule(this.api, config.orgSlug, inventoryMapping);
3286
3355
  this.orders = buildModule(this.api, config.orgSlug, ordersMapping);
3356
+ this.b2b = this.orders;
3287
3357
  this.crm = buildModule(this.api, config.orgSlug, crmMapping);
3288
3358
  this.pos = buildModule(this.api, config.orgSlug, posMapping);
3289
3359
  this.accounting = buildModule(this.api, config.orgSlug, accountingMapping);
@@ -3864,6 +3934,7 @@ var ScrymeServerSDK = class {
3864
3934
  };
3865
3935
  this.inventory = buildModule(this.api, config.orgSlug, inventoryMapping);
3866
3936
  this.orders = buildModule(this.api, config.orgSlug, ordersMapping);
3937
+ this.b2b = this.orders;
3867
3938
  this.crm = buildModule(this.api, config.orgSlug, crmMapping);
3868
3939
  this.pos = buildModule(this.api, config.orgSlug, posMapping);
3869
3940
  this.accounting = buildModule(this.api, config.orgSlug, accountingMapping);
@@ -4137,72 +4208,6 @@ function createServerSDK(config = {}) {
4137
4208
  };
4138
4209
  return new ScrymeServerSDK(finalConfig);
4139
4210
  }
4140
-
4141
- // src/index.ts
4142
- function getEnvOrgSlug() {
4143
- if (typeof process !== "undefined" && process.env) {
4144
- const slug = process.env.SCRYME_ORG_SLUG || process.env.NEXT_PUBLIC_SCRYME_ORG_SLUG;
4145
- if (slug) return slug;
4146
- }
4147
- try {
4148
- const getMeta = new Function("return typeof import.meta !== 'undefined' ? import.meta : undefined");
4149
- const meta = getMeta();
4150
- if (meta && meta.env) {
4151
- const slug = meta.env.VITE_SCRYME_ORG_SLUG || meta.env.SCRYME_ORG_SLUG;
4152
- if (slug) return slug;
4153
- }
4154
- } catch (e) {
4155
- }
4156
- return void 0;
4157
- }
4158
- function expectsOrgSlug(fn) {
4159
- const fnStr = fn.toString();
4160
- const match = fnStr.match(/^\s*(?:async\s+)?\(([^)]+)\)/);
4161
- if (!match) {
4162
- const singleMatch = fnStr.match(/^\s*(\w+)\s*=>/);
4163
- return singleMatch ? singleMatch[1] === "orgSlug" : false;
4164
- }
4165
- const firstParam = match[1].split(",")[0].split(":")[0].trim();
4166
- return firstParam === "orgSlug";
4167
- }
4168
- function getStringParamCount(fn) {
4169
- const fnStr = fn.toString();
4170
- const match = fnStr.match(/^\s*(?:async\s+)?\(([^)]+)\)/);
4171
- if (!match) return 0;
4172
- const params = match[1].split(",").map((p) => p.trim());
4173
- let count = 0;
4174
- for (const param of params) {
4175
- const cleanParam = param.split(":")[0].split("=")[0].trim();
4176
- const lower = cleanParam.toLowerCase();
4177
- if (lower === "params" || lower === "options" || lower.endsWith("dto") || lower.endsWith("body") || lower.endsWith("payload")) {
4178
- break;
4179
- }
4180
- count++;
4181
- }
4182
- return count;
4183
- }
4184
- var getScrymeV3API2 = (axiosInstance, defaultOrgSlug) => {
4185
- const api = getScrymeV3API(axiosInstance);
4186
- return new Proxy(api, {
4187
- get(target, prop, receiver) {
4188
- const originalValue = Reflect.get(target, prop, receiver);
4189
- if (typeof originalValue === "function") {
4190
- if (expectsOrgSlug(originalValue)) {
4191
- return function(...args) {
4192
- const stringParamsExpected = getStringParamCount(originalValue);
4193
- const stringArgsPassed = args.filter((arg) => typeof arg === "string").length;
4194
- if (stringArgsPassed < stringParamsExpected) {
4195
- const envSlug = defaultOrgSlug || getEnvOrgSlug() || "default-org";
4196
- return originalValue.apply(this, [envSlug, ...args]);
4197
- }
4198
- return originalValue.apply(this, args);
4199
- };
4200
- }
4201
- }
4202
- return originalValue;
4203
- }
4204
- });
4205
- };
4206
4211
  // Annotate the CommonJS export names for ESM import in node:
4207
4212
  0 && (module.exports = {
4208
4213
  AddDepartmentMemberDtoRole,