@viu/emporix-sdk 2.10.0 → 2.11.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/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # @viu/emporix-sdk
2
2
 
3
+ ## 2.11.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#114](https://github.com/viuteam/emporix-sdk/pull/114) [`ac2b2c8`](https://github.com/viuteam/emporix-sdk/commit/ac2b2c890521da017b3ef44ff15bdf6b16d69bb9) Thanks [@amnael1](https://github.com/amnael1)! - feat: invoke Emporix cloud functions
8
+
9
+ Adds `client.cloudFunctions.invoke<TRes, TReq>(functionId, { method?, path?,
10
+ body?, query?, headers? }, auth)` — a generic call to tenant cloud functions
11
+ (`/cloud-functions/{tenant}/functions/{id}[/sub]`), with GET/POST/PUT/DELETE and
12
+ service / customer / anonymous / raw auth (default anonymous). Adds the React
13
+ hooks `useInvokeCloudFunction` (mutation, any method) and `useCloudFunction`
14
+ (GET-style query with caching), both with auto-auth (customer-if-token-else-
15
+ anonymous) and an optional override.
16
+
3
17
  ## 2.10.0
4
18
 
5
19
  ### Minor Changes
@@ -1,4 +1,4 @@
1
- import { C as ClientContext, b as AuthContext } from './context-BBKOwNW6.cjs';
1
+ import { C as ClientContext, b as AuthContext } from './context-CmShWI_R.cjs';
2
2
 
3
3
  type DistributionChannel = 'ASSORTMENT' | 'HOME_DELIVERY' | 'PICKUP';
4
4
  type Availability$1 = {
@@ -1,4 +1,4 @@
1
- import { C as ClientContext, b as AuthContext } from './context-BBKOwNW6.js';
1
+ import { C as ClientContext, b as AuthContext } from './context-CmShWI_R.js';
2
2
 
3
3
  type DistributionChannel = 'ASSORTMENT' | 'HOME_DELIVERY' | 'PICKUP';
4
4
  type Availability$1 = {
package/dist/cart.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { C as ClientContext, b as AuthContext } from './context-BBKOwNW6.cjs';
1
+ import { C as ClientContext, b as AuthContext } from './context-CmShWI_R.cjs';
2
2
 
3
3
  /**
4
4
  * Access control identifier that determines who can view or manage the cart.
package/dist/cart.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { C as ClientContext, b as AuthContext } from './context-BBKOwNW6.js';
1
+ import { C as ClientContext, b as AuthContext } from './context-CmShWI_R.js';
2
2
 
3
3
  /**
4
4
  * Access control identifier that determines who can view or manage the cart.
@@ -1,4 +1,4 @@
1
- import { C as ClientContext, b as AuthContext, P as PaginatedItems } from './context-BBKOwNW6.cjs';
1
+ import { C as ClientContext, b as AuthContext, P as PaginatedItems } from './context-CmShWI_R.cjs';
2
2
  import { Product } from './product.cjs';
3
3
 
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { C as ClientContext, b as AuthContext, P as PaginatedItems } from './context-BBKOwNW6.js';
1
+ import { C as ClientContext, b as AuthContext, P as PaginatedItems } from './context-CmShWI_R.js';
2
2
  import { Product } from './product.js';
3
3
 
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { C as ClientContext, b as AuthContext } from './context-BBKOwNW6.cjs';
1
+ import { C as ClientContext, b as AuthContext } from './context-CmShWI_R.cjs';
2
2
 
3
3
  /**
4
4
  * Information about the customer's address.
@@ -1,4 +1,4 @@
1
- import { C as ClientContext, b as AuthContext } from './context-BBKOwNW6.js';
1
+ import { C as ClientContext, b as AuthContext } from './context-CmShWI_R.js';
2
2
 
3
3
  /**
4
4
  * Information about the customer's address.
@@ -1,4 +1,4 @@
1
- import { C as ClientContext, b as AuthContext } from './context-BBKOwNW6.cjs';
1
+ import { C as ClientContext, b as AuthContext } from './context-CmShWI_R.cjs';
2
2
  import { L as LegalEntity, e as LegalEntityCreate, f as LegalEntityUpdate } from './types.gen-C_wOXYZB.cjs';
3
3
  export { A as AccountLimit, d as CustomerGroup, g as LegalInfo } from './types.gen-C_wOXYZB.cjs';
4
4
 
@@ -1,4 +1,4 @@
1
- import { C as ClientContext, b as AuthContext } from './context-BBKOwNW6.js';
1
+ import { C as ClientContext, b as AuthContext } from './context-CmShWI_R.js';
2
2
  import { L as LegalEntity, e as LegalEntityCreate, f as LegalEntityUpdate } from './types.gen-C_wOXYZB.js';
3
3
  export { A as AccountLimit, d as CustomerGroup, g as LegalInfo } from './types.gen-C_wOXYZB.js';
4
4
 
@@ -1,4 +1,4 @@
1
- import { C as ClientContext, b as AuthContext } from './context-BBKOwNW6.cjs';
1
+ import { C as ClientContext, b as AuthContext } from './context-CmShWI_R.cjs';
2
2
  import { C as ContactAssignment, a as ContactAssignmentCreate, b as ContactAssignmentUpdate } from './types.gen-C_wOXYZB.cjs';
3
3
 
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { C as ClientContext, b as AuthContext } from './context-BBKOwNW6.js';
1
+ import { C as ClientContext, b as AuthContext } from './context-CmShWI_R.js';
2
2
  import { C as ContactAssignment, a as ContactAssignmentCreate, b as ContactAssignmentUpdate } from './types.gen-C_wOXYZB.js';
3
3
 
4
4
  /**
@@ -3,7 +3,7 @@ type LogLevel = "trace" | "debug" | "info" | "warn" | "error" | "silent";
3
3
  /** Numeric ordering used for fast comparison. */
4
4
  declare const LEVEL: Record<LogLevel, number>;
5
5
  /** Services that bind their own logger and are independently level-controllable. */
6
- type ServiceName = "customer" | "product" | "category" | "cart" | "checkout" | "payment" | "price" | "media" | "segment" | "site" | "session-context" | "customer-management" | "iam" | "orders" | "sales-orders" | "availability" | "configuration" | "shopping-list" | "ai-rag-indexer" | "sequential-id" | "fee" | "webhook" | "schema" | "ai" | "tax" | "coupon" | "reward-points" | "brand" | "label" | "country" | "currency" | "shipping" | "returns" | "sepa-export" | "indexing" | "unit-handling" | "catalog" | "vendor" | "pick-pack" | "customer-admin" | "approval" | "http" | "auth";
6
+ type ServiceName = "customer" | "product" | "category" | "cart" | "checkout" | "payment" | "price" | "media" | "segment" | "site" | "session-context" | "customer-management" | "iam" | "orders" | "sales-orders" | "availability" | "configuration" | "shopping-list" | "ai-rag-indexer" | "sequential-id" | "fee" | "webhook" | "schema" | "ai" | "tax" | "coupon" | "reward-points" | "brand" | "label" | "country" | "currency" | "shipping" | "returns" | "sepa-export" | "indexing" | "unit-handling" | "catalog" | "vendor" | "pick-pack" | "customer-admin" | "approval" | "cloud-functions" | "http" | "auth";
7
7
  /** Arbitrary structured fields attached to a log line. */
8
8
  interface LogFields {
9
9
  [key: string]: unknown;
@@ -3,7 +3,7 @@ type LogLevel = "trace" | "debug" | "info" | "warn" | "error" | "silent";
3
3
  /** Numeric ordering used for fast comparison. */
4
4
  declare const LEVEL: Record<LogLevel, number>;
5
5
  /** Services that bind their own logger and are independently level-controllable. */
6
- type ServiceName = "customer" | "product" | "category" | "cart" | "checkout" | "payment" | "price" | "media" | "segment" | "site" | "session-context" | "customer-management" | "iam" | "orders" | "sales-orders" | "availability" | "configuration" | "shopping-list" | "ai-rag-indexer" | "sequential-id" | "fee" | "webhook" | "schema" | "ai" | "tax" | "coupon" | "reward-points" | "brand" | "label" | "country" | "currency" | "shipping" | "returns" | "sepa-export" | "indexing" | "unit-handling" | "catalog" | "vendor" | "pick-pack" | "customer-admin" | "approval" | "http" | "auth";
6
+ type ServiceName = "customer" | "product" | "category" | "cart" | "checkout" | "payment" | "price" | "media" | "segment" | "site" | "session-context" | "customer-management" | "iam" | "orders" | "sales-orders" | "availability" | "configuration" | "shopping-list" | "ai-rag-indexer" | "sequential-id" | "fee" | "webhook" | "schema" | "ai" | "tax" | "coupon" | "reward-points" | "brand" | "label" | "country" | "currency" | "shipping" | "returns" | "sepa-export" | "indexing" | "unit-handling" | "catalog" | "vendor" | "pick-pack" | "customer-admin" | "approval" | "cloud-functions" | "http" | "auth";
7
7
  /** Arbitrary structured fields attached to a log line. */
8
8
  interface LogFields {
9
9
  [key: string]: unknown;
@@ -1,4 +1,4 @@
1
- import { C as ClientContext, b as AuthContext } from './context-BBKOwNW6.cjs';
1
+ import { C as ClientContext, b as AuthContext } from './context-CmShWI_R.cjs';
2
2
 
3
3
  type AssignmentCreateRequest = {
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { C as ClientContext, b as AuthContext } from './context-BBKOwNW6.js';
1
+ import { C as ClientContext, b as AuthContext } from './context-CmShWI_R.js';
2
2
 
3
3
  type AssignmentCreateRequest = {
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { C as ClientContext, A as AnonymousSession, b as AuthContext } from './context-BBKOwNW6.cjs';
1
+ import { C as ClientContext, A as AnonymousSession, b as AuthContext } from './context-CmShWI_R.cjs';
2
2
 
3
3
  type AccountId = {
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { C as ClientContext, A as AnonymousSession, b as AuthContext } from './context-BBKOwNW6.js';
1
+ import { C as ClientContext, A as AnonymousSession, b as AuthContext } from './context-CmShWI_R.js';
2
2
 
3
3
  type AccountId = {
4
4
  /**
package/dist/index.cjs CHANGED
@@ -2902,6 +2902,28 @@ var FeeService = class {
2902
2902
  }
2903
2903
  };
2904
2904
 
2905
+ // src/services/cloud-functions.ts
2906
+ var CloudFunctionsService = class {
2907
+ constructor(ctx) {
2908
+ this.ctx = ctx;
2909
+ }
2910
+ ctx;
2911
+ base() {
2912
+ return `/cloud-functions/${this.ctx.tenant}/functions`;
2913
+ }
2914
+ async invoke(functionId, options = {}, authCtx = auth.anonymous()) {
2915
+ const sub = options.path ? `/${options.path.replace(/^\//, "")}` : "";
2916
+ return this.ctx.http.request({
2917
+ method: options.method ?? "POST",
2918
+ path: `${this.base()}/${functionId}${sub}`,
2919
+ auth: authCtx,
2920
+ ...options.body !== void 0 ? { body: options.body } : {},
2921
+ ...options.query ? { query: options.query } : {},
2922
+ ...options.headers ? { headers: options.headers } : {}
2923
+ });
2924
+ }
2925
+ };
2926
+
2905
2927
  // src/services/webhook.ts
2906
2928
  var SERVICE8 = { kind: "service" };
2907
2929
  var WebhookService = class {
@@ -5074,7 +5096,7 @@ var ApprovalService = class {
5074
5096
  };
5075
5097
 
5076
5098
  // package.json
5077
- var version = "2.10.0";
5099
+ var version = "2.11.0";
5078
5100
 
5079
5101
  // src/version.ts
5080
5102
  var SDK_VERSION = version;
@@ -5105,6 +5127,7 @@ var EmporixClient = class {
5105
5127
  ragIndexer;
5106
5128
  sequentialIds;
5107
5129
  fees;
5130
+ cloudFunctions;
5108
5131
  webhooks;
5109
5132
  schemas;
5110
5133
  ai;
@@ -5205,6 +5228,7 @@ var EmporixClient = class {
5205
5228
  this.ragIndexer = new RagIndexerService(mk("ai-rag-indexer"));
5206
5229
  this.sequentialIds = new SequentialIdService(mk("sequential-id"));
5207
5230
  this.fees = new FeeService(mk("fee"));
5231
+ this.cloudFunctions = new CloudFunctionsService(mk("cloud-functions"));
5208
5232
  this.webhooks = new WebhookService(mk("webhook"));
5209
5233
  this.schemas = new SchemaService(mk("schema"));
5210
5234
  this.ai = new AiService(mk("ai"));
@@ -5271,6 +5295,7 @@ exports.CatalogService = CatalogService;
5271
5295
  exports.CategoryService = CategoryService;
5272
5296
  exports.CheckoutService = CheckoutService;
5273
5297
  exports.ClientConfigService = ClientConfigService;
5298
+ exports.CloudFunctionsService = CloudFunctionsService;
5274
5299
  exports.CompaniesService = CompaniesService;
5275
5300
  exports.ContactsService = ContactsService;
5276
5301
  exports.CountryService = CountryService;