@kirimdev/sdk 3.1.1 → 3.3.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.
@@ -0,0 +1,2 @@
1
+ export declare const SDK_VERSION: "3.3.0";
2
+ //# sourceMappingURL=version.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/generated/version.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,WAAW,EAAG,OAAgB,CAAA"}
@@ -0,0 +1,6 @@
1
+ // AUTO-GENERATED by scripts/generate-version.ts — DO NOT EDIT.
2
+ // Regenerated on every prebuild / pretypecheck / pretest from
3
+ // package.json so the User-Agent header stays in sync with the
4
+ // published version.
5
+ export const SDK_VERSION = "3.3.0";
6
+ //# sourceMappingURL=version.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/generated/version.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,8DAA8D;AAC9D,+DAA+D;AAC/D,qBAAqB;AAErB,MAAM,CAAC,MAAM,WAAW,GAAG,OAAgB,CAAA"}
@@ -0,0 +1,6 @@
1
+ // AUTO-GENERATED by scripts/generate-version.ts — DO NOT EDIT.
2
+ // Regenerated on every prebuild / pretypecheck / pretest from
3
+ // package.json so the User-Agent header stays in sync with the
4
+ // published version.
5
+
6
+ export const SDK_VERSION = "3.3.0" as const
package/dist/index.d.ts CHANGED
@@ -6,8 +6,10 @@
6
6
  */
7
7
  export { Kirim, SDK_VERSION, type KirimOptions } from './client.js';
8
8
  export { PhoneNumberClient } from './resources/phone-number.js';
9
+ export type { TemplateSyncResult } from './resources/templates.js';
9
10
  export type { Page, Paginator } from './pagination.js';
10
11
  export type { RequestOptions } from './http.js';
11
12
  export { KirimError, InvalidRequestError, AuthenticationError, PermissionError, NotFoundError, ConflictError, RateLimitError, ApiServerError, ConnectionError, type KirimErrorType, type KirimErrorPayload, } from './errors.js';
13
+ export type { Customer, CustomerStatus, CustomerWithAccounts, CustomerWhatsappAccountSummary, CustomerSetupLink, CustomerSetupLinkStatus, CustomerSetupLinkWithToken, CreateCustomerParams, UpdateCustomerParams, ListCustomersParams, CreateSetupLinkParams, UpdateSetupLinkParams, } from './resources/customers.js';
12
14
  export type { MeContext, Account, ListAccountsParams, Message, MessageListItem, SendMessageParams, ListMessagesParams, MessageMediaRedirect, Template, TemplateListItem, ListTemplatesParams, RetrieveTemplateParams, Conversation, ConversationListItem, ListConversationsParams, UpdateConversationParams, AttachConversationLabelParams, Contact, ContactListItem, ListContactsParams, CreateContactParams, UpdateContactParams, AttachContactLabelParams, BulkLabelContactsParams, Label, LabelListItem, ListLabelsParams, CreateLabelParams, UpdateLabelParams, WebhookSubscription, WebhookSubscriptionListItem, CreateWebhookSubscriptionParams, UpdateWebhookSubscriptionParams, AddWebhookSecret, WebhookDelivery, WebhookDeliveryListItem, ListWebhookDeliveriesParams, BulkReplayParams, BulkReplayResult, } from './types.js';
13
15
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,KAAK,YAAY,EAAE,MAAM,aAAa,CAAA;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAA;AAE/D,YAAY,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AACtD,YAAY,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAE/C,OAAO,EACL,UAAU,EACV,mBAAmB,EACnB,mBAAmB,EACnB,eAAe,EACf,aAAa,EACb,aAAa,EACb,cAAc,EACd,cAAc,EACd,eAAe,EACf,KAAK,cAAc,EACnB,KAAK,iBAAiB,GACvB,MAAM,aAAa,CAAA;AAEpB,YAAY,EACV,SAAS,EACT,OAAO,EACP,kBAAkB,EAClB,OAAO,EACP,eAAe,EACf,iBAAiB,EACjB,kBAAkB,EAClB,oBAAoB,EACpB,QAAQ,EACR,gBAAgB,EAChB,mBAAmB,EACnB,sBAAsB,EACtB,YAAY,EACZ,oBAAoB,EACpB,uBAAuB,EACvB,wBAAwB,EACxB,6BAA6B,EAC7B,OAAO,EACP,eAAe,EACf,kBAAkB,EAClB,mBAAmB,EACnB,mBAAmB,EACnB,wBAAwB,EACxB,uBAAuB,EACvB,KAAK,EACL,aAAa,EACb,gBAAgB,EAChB,iBAAiB,EACjB,iBAAiB,EACjB,mBAAmB,EACnB,2BAA2B,EAC3B,+BAA+B,EAC/B,+BAA+B,EAC/B,gBAAgB,EAChB,eAAe,EACf,uBAAuB,EACvB,2BAA2B,EAC3B,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,YAAY,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,KAAK,YAAY,EAAE,MAAM,aAAa,CAAA;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAA;AAC/D,YAAY,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAA;AAElE,YAAY,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AACtD,YAAY,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAE/C,OAAO,EACL,UAAU,EACV,mBAAmB,EACnB,mBAAmB,EACnB,eAAe,EACf,aAAa,EACb,aAAa,EACb,cAAc,EACd,cAAc,EACd,eAAe,EACf,KAAK,cAAc,EACnB,KAAK,iBAAiB,GACvB,MAAM,aAAa,CAAA;AAEpB,YAAY,EACV,QAAQ,EACR,cAAc,EACd,oBAAoB,EACpB,8BAA8B,EAC9B,iBAAiB,EACjB,uBAAuB,EACvB,0BAA0B,EAC1B,oBAAoB,EACpB,oBAAoB,EACpB,mBAAmB,EACnB,qBAAqB,EACrB,qBAAqB,GACtB,MAAM,0BAA0B,CAAA;AAEjC,YAAY,EACV,SAAS,EACT,OAAO,EACP,kBAAkB,EAClB,OAAO,EACP,eAAe,EACf,iBAAiB,EACjB,kBAAkB,EAClB,oBAAoB,EACpB,QAAQ,EACR,gBAAgB,EAChB,mBAAmB,EACnB,sBAAsB,EACtB,YAAY,EACZ,oBAAoB,EACpB,uBAAuB,EACvB,wBAAwB,EACxB,6BAA6B,EAC7B,OAAO,EACP,eAAe,EACf,kBAAkB,EAClB,mBAAmB,EACnB,mBAAmB,EACnB,wBAAwB,EACxB,uBAAuB,EACvB,KAAK,EACL,aAAa,EACb,gBAAgB,EAChB,iBAAiB,EACjB,iBAAiB,EACjB,mBAAmB,EACnB,2BAA2B,EAC3B,+BAA+B,EAC/B,+BAA+B,EAC/B,gBAAgB,EAChB,eAAe,EACf,uBAAuB,EACvB,2BAA2B,EAC3B,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,YAAY,CAAA"}
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,KAAK,EAAE,WAAW,EAAqB,MAAM,aAAa,CAAA;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAA;AAK/D,OAAO,EACL,UAAU,EACV,mBAAmB,EACnB,mBAAmB,EACnB,eAAe,EACf,aAAa,EACb,aAAa,EACb,cAAc,EACd,cAAc,EACd,eAAe,GAGhB,MAAM,aAAa,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,KAAK,EAAE,WAAW,EAAqB,MAAM,aAAa,CAAA;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAA;AAM/D,OAAO,EACL,UAAU,EACV,mBAAmB,EACnB,mBAAmB,EACnB,eAAe,EACf,aAAa,EACb,aAAa,EACb,cAAc,EACd,cAAc,EACd,eAAe,GAGhB,MAAM,aAAa,CAAA"}
@@ -0,0 +1,148 @@
1
+ import type { HttpClient, RequestOptions } from '../http.js';
2
+ import { Paginator } from '../pagination.js';
3
+ /**
4
+ * Hand-authored types for the Customer resource.
5
+ *
6
+ * These types intentionally do NOT reference `paths`/`components` from
7
+ * the generated OpenAPI schema. Access is gated per-org by the
8
+ * `customers_enabled` entitlement (Business plan and above); orgs
9
+ * without the feature receive HTTP 402 from the live routes. Keeping
10
+ * the SDK surface fully owned by this file matches the dashboard-only
11
+ * resources pattern and keeps response shapes stable across plans.
12
+ *
13
+ * Once the feature surface stabilises across plans, the manual types
14
+ * here can be replaced with `paths['/customers']['get']['responses']…`
15
+ * imports for consistency with the rest of `types.ts`.
16
+ */
17
+ export type CustomerStatus = 'pending' | 'active' | 'suspended' | 'archived';
18
+ export interface Customer {
19
+ id: string;
20
+ object: 'customer';
21
+ name: string;
22
+ email: string | null;
23
+ status: CustomerStatus;
24
+ metadata: Record<string, unknown> | null;
25
+ archived_at: string | null;
26
+ team_id: string;
27
+ created_at: string;
28
+ updated_at: string;
29
+ }
30
+ export interface CustomerWhatsappAccountSummary {
31
+ phone_number_id: string | null;
32
+ phone_number: string | null;
33
+ name: string | null;
34
+ status: string;
35
+ onboarded_at: string | null;
36
+ }
37
+ export interface CustomerWithAccounts extends Customer {
38
+ whatsapp_accounts: CustomerWhatsappAccountSummary[];
39
+ }
40
+ export interface ListCustomersParams {
41
+ status?: CustomerStatus;
42
+ search?: string;
43
+ limit?: number;
44
+ cursor?: string;
45
+ }
46
+ export interface CreateCustomerParams {
47
+ team_id?: string;
48
+ name: string;
49
+ email?: string;
50
+ metadata?: Record<string, unknown>;
51
+ }
52
+ export interface UpdateCustomerParams {
53
+ name?: string;
54
+ email?: string | null;
55
+ metadata?: Record<string, unknown> | null;
56
+ status?: 'pending' | 'active' | 'suspended';
57
+ }
58
+ export type CustomerSetupLinkStatus = 'active' | 'consumed' | 'expired' | 'revoked';
59
+ export interface CustomerSetupLink {
60
+ id: string;
61
+ object: 'customer_setup_link';
62
+ customer_id: string;
63
+ status: CustomerSetupLinkStatus;
64
+ token_last4: string;
65
+ expires_at: string;
66
+ consumed_at: string | null;
67
+ /** Where the tenant lands after successful Embedded Signup. */
68
+ success_redirect_url: string | null;
69
+ /** Where the tenant lands on failure (cancelled / expired / etc.). */
70
+ failure_redirect_url: string | null;
71
+ created_at: string;
72
+ }
73
+ /**
74
+ * Returned EXACTLY ONCE on create. Persist `setup_url` immediately —
75
+ * the plaintext token is embedded in the URL's path and is never
76
+ * recoverable from a list/get call.
77
+ *
78
+ * Earlier API versions returned a duplicate `token` field alongside
79
+ * `setup_url`. It was dropped because it duplicated what's already in
80
+ * the URL and triggered secret-scanning false positives. If you were
81
+ * reading `link.token` directly, switch to parsing the path segment
82
+ * out of `link.setup_url` (the last segment is the plaintext token).
83
+ */
84
+ export interface CustomerSetupLinkWithToken extends CustomerSetupLink {
85
+ setup_url: string;
86
+ }
87
+ export interface CreateSetupLinkParams {
88
+ expires_in_hours?: number;
89
+ /**
90
+ * Where to redirect the end-customer's browser AFTER a successful
91
+ * Embedded Signup. Must be `https://` (or `http://localhost` in dev).
92
+ * On success we append `?customer_id=...&account_id=...&status=success`.
93
+ */
94
+ success_redirect_url?: string;
95
+ /**
96
+ * Where to redirect on failure (link expired/revoked/consumed, Meta
97
+ * token exchange failed, signup cancelled, etc.). Same rules. We
98
+ * append `?customer_id=...&status=failed&reason=<code>`.
99
+ */
100
+ failure_redirect_url?: string;
101
+ }
102
+ export interface UpdateSetupLinkParams {
103
+ /** Pass `null` to clear. */
104
+ success_redirect_url?: string | null;
105
+ failure_redirect_url?: string | null;
106
+ }
107
+ export declare class CustomersResource {
108
+ private readonly http;
109
+ constructor(http: HttpClient);
110
+ list(params?: ListCustomersParams, options?: RequestOptions): Paginator<Customer>;
111
+ create(params: CreateCustomerParams, options?: RequestOptions): Promise<Customer>;
112
+ retrieve(id: string, options?: RequestOptions): Promise<CustomerWithAccounts>;
113
+ update(id: string, params: UpdateCustomerParams, options?: RequestOptions): Promise<Customer>;
114
+ /**
115
+ * Soft-archive. Mirrors `DELETE /customers/{id}` on the wire — the
116
+ * customer row is preserved so message history stays addressable.
117
+ */
118
+ archive(id: string, options?: RequestOptions): Promise<{
119
+ id: string;
120
+ object: 'customer';
121
+ archived: true;
122
+ }>;
123
+ /**
124
+ * List setup links for a customer. Returns up to the 50 most-recent;
125
+ * plaintext token is never re-exposed.
126
+ */
127
+ listSetupLinks(customerId: string, params?: {
128
+ status?: CustomerSetupLinkStatus;
129
+ }, options?: RequestOptions): Paginator<CustomerSetupLink>;
130
+ /**
131
+ * Patch redirect URLs on an active setup link. Pass `null` to clear
132
+ * a redirect entirely; consumed/expired/revoked links are read-only
133
+ * and return 409.
134
+ */
135
+ updateSetupLink(customerId: string, linkId: string, params: UpdateSetupLinkParams, options?: RequestOptions): Promise<CustomerSetupLink>;
136
+ /**
137
+ * Generate a one-time setup link. The plaintext token + URL are
138
+ * returned EXACTLY ONCE — store them before discarding the response.
139
+ */
140
+ createSetupLink(customerId: string, params?: CreateSetupLinkParams, options?: RequestOptions): Promise<CustomerSetupLinkWithToken>;
141
+ revokeSetupLink(customerId: string, linkId: string, options?: RequestOptions): Promise<{
142
+ id: string;
143
+ object: 'customer_setup_link';
144
+ revoked: true;
145
+ status: CustomerSetupLinkStatus;
146
+ }>;
147
+ }
148
+ //# sourceMappingURL=customers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"customers.d.ts","sourceRoot":"","sources":["../../src/resources/customers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAE5C;;;;;;;;;;;;;GAaG;AAEH,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG,QAAQ,GAAG,WAAW,GAAG,UA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AE,uBAAuB,CAAA;KAChC,CAAC;CAOH"}
@@ -0,0 +1,96 @@
1
+ import { Paginator } from '../pagination.js';
2
+ export class CustomersResource {
3
+ http;
4
+ constructor(http) {
5
+ this.http = http;
6
+ }
7
+ list(params, options) {
8
+ return new Paginator(this.http, {
9
+ path: '/customers',
10
+ ...(params
11
+ ? {
12
+ query: params,
13
+ }
14
+ : {}),
15
+ }, options);
16
+ }
17
+ create(params, options) {
18
+ return this.http.requestData({
19
+ method: 'POST',
20
+ path: '/customers',
21
+ body: params,
22
+ ...(options ? { options } : {}),
23
+ });
24
+ }
25
+ retrieve(id, options) {
26
+ return this.http.requestData({
27
+ method: 'GET',
28
+ path: `/customers/${encodeURIComponent(id)}`,
29
+ ...(options ? { options } : {}),
30
+ });
31
+ }
32
+ update(id, params, options) {
33
+ return this.http.requestData({
34
+ method: 'PATCH',
35
+ path: `/customers/${encodeURIComponent(id)}`,
36
+ body: params,
37
+ ...(options ? { options } : {}),
38
+ });
39
+ }
40
+ /**
41
+ * Soft-archive. Mirrors `DELETE /customers/{id}` on the wire — the
42
+ * customer row is preserved so message history stays addressable.
43
+ */
44
+ archive(id, options) {
45
+ return this.http.requestData({
46
+ method: 'DELETE',
47
+ path: `/customers/${encodeURIComponent(id)}`,
48
+ ...(options ? { options } : {}),
49
+ });
50
+ }
51
+ /**
52
+ * List setup links for a customer. Returns up to the 50 most-recent;
53
+ * plaintext token is never re-exposed.
54
+ */
55
+ listSetupLinks(customerId, params, options) {
56
+ return new Paginator(this.http, {
57
+ path: `/customers/${encodeURIComponent(customerId)}/setup_links`,
58
+ ...(params
59
+ ? { query: params }
60
+ : {}),
61
+ }, options);
62
+ }
63
+ /**
64
+ * Patch redirect URLs on an active setup link. Pass `null` to clear
65
+ * a redirect entirely; consumed/expired/revoked links are read-only
66
+ * and return 409.
67
+ */
68
+ updateSetupLink(customerId, linkId, params, options) {
69
+ return this.http.requestData({
70
+ method: 'PATCH',
71
+ path: `/customers/${encodeURIComponent(customerId)}/setup_links/${encodeURIComponent(linkId)}`,
72
+ body: params,
73
+ ...(options ? { options } : {}),
74
+ });
75
+ }
76
+ /**
77
+ * Generate a one-time setup link. The plaintext token + URL are
78
+ * returned EXACTLY ONCE — store them before discarding the response.
79
+ */
80
+ createSetupLink(customerId, params, options) {
81
+ return this.http.requestData({
82
+ method: 'POST',
83
+ path: `/customers/${encodeURIComponent(customerId)}/setup_links`,
84
+ body: params ?? {},
85
+ ...(options ? { options } : {}),
86
+ });
87
+ }
88
+ revokeSetupLink(customerId, linkId, options) {
89
+ return this.http.requestData({
90
+ method: 'DELETE',
91
+ path: `/customers/${encodeURIComponent(customerId)}/setup_links/${encodeURIComponent(linkId)}`,
92
+ ...(options ? { options } : {}),
93
+ });
94
+ }
95
+ }
96
+ //# sourceMappingURL=customers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"customers.js","sourceRoot":"","sources":["../../src/resources/customers.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAuH5C,MAAM,OAAO,iBAAiB;IACC;IAA7B,YAA6B,IAAgB;QAAhB,SAAI,GAAJ,IAAI,CAAY;IAAG,CAAC;IAEjD,IAAI,CAAC,MAA4B,EAAE,OAAwB;QACzD,OAAO,IAAI,SAAS,CAClB,IAAI,CAAC,IAAI,EACT;YACE,IAAI,EAAE,YAAY;YAClB,GAAG,CAAC,MAAM;gBACR,CAAC,CAAC;oBACE,KAAK,EAAE,MAAsE;iBAC9E;gBACH,CAAC,CAAC,EAAE,CAAC;SACR,EACD,OAAO,CACR,CAAA;IACH,CAAC;IAED,MAAM,CAAC,MAA4B,EAAE,OAAwB;QAC3D,OAAO,IAAI,CAAC,IAAI,CAAC,WAAW,CAAW;YACrC,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,YAAY;YAClB,IAAI,EAAE,MAAM;YACZ,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EA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,EACD,OAAO,CACR,CAAA;IACH,CAAC;IAED;;;;OAIG;IACH,eAAe,CACb,UAAkB,EAClB,MAAc,EACd,MAA6B,EAC7B,OAAwB;QAExB,OAAO,IAAI,CAAC,IAAI,CAAC,WAAW,CAAoB;YAC9C,MAAM,EAAE,OAAO;YACf,IAAI,EAAE,cAAc,kBAAkB,CAAC,UAAU,CAAC,gBAAgB,kBAAkB,CAAC,MAAM,CAAC,EAAE;YAC9F,IAAI,EAAE,MAAM;YACZ,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAChC,CAAC,CAAA;IACJ,CAAC;IAED;;;OAGG;IACH,eAAe,CACb,UAAkB,EAClB,MAA8B,EAC9B,OAAwB;QAExB,OAAO,IAAI,CAAC,IAAI,CAAC,WAAW,CAA6B;YACvD,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,cAAc,kBAAkB,CAAC,UAAU,CAAC,cAAc;YAChE,IAAI,EAAE,MAAM,IAAI,EAAE;YAClB,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAChC,CAAC,CAAA;IACJ,CAAC;IAED,eAAe,CACb,UAAkB,EAClB,MAAc,EACd,OAAwB;QAOxB,OAAO,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC;YAC3B,MAAM,EAAE,QAAQ;YAChB,IAAI,EAAE,cAAc,kBAAkB,CAAC,UAAU,CAAC,gBAAgB,kBAAkB,CAAC,MAAM,CAAC,EAAE;YAC9F,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAChC,CAAC,CAAA;IACJ,CAAC;CACF"}
@@ -13,5 +13,23 @@ export declare class TemplatesResource {
13
13
  constructor(http: HttpClient, prefix: string);
14
14
  list(params?: ListTemplatesParams, options?: RequestOptions): Paginator<TemplateListItem>;
15
15
  retrieve(name: string, params?: RetrieveTemplateParams, options?: RequestOptions): Promise<Template>;
16
+ /**
17
+ * Pull the latest template inventory from Meta and upsert into the
18
+ * Kirim DB for this WhatsApp account. Idempotent — call any time,
19
+ * returns a `{ created, updated, synced }` summary. Useful for
20
+ * platform integrations (multi-tenant Customers) so an automation
21
+ * can refresh templates after onboarding without waiting for the
22
+ * operator to click "Sync" in the dashboard.
23
+ */
24
+ sync(options?: RequestOptions): Promise<TemplateSyncResult>;
25
+ }
26
+ export interface TemplateSyncResult {
27
+ object: 'template_sync_result';
28
+ /** Total number of templates Meta returned. */
29
+ synced: number;
30
+ /** Of those, how many were freshly inserted in Kirim. */
31
+ created: number;
32
+ /** Of those, how many were upserted onto an existing row. */
33
+ updated: number;
16
34
  }
17
35
  //# sourceMappingURL=templates.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../../src/resources/templates.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAC5C,OAAO,KAAK,EACV,mBAAmB,EACnB,sBAAsB,EACtB,QAAQ,EACR,gBAAgB,EACjB,MAAM,aAAa,CAAA;AAEpB;;;;;GAKG;AACH,qBAAa,iBAAiB;IAE1B,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,MAAM;gBADN,IAAI,EAAE,UAAU,EAChB,MAAM,EAAE,MAAM;IAGjC,IAAI,CAAC,MAAM,CAAC,EAAE,mBAAmB,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,SAAS,CAAC,gBAAgB,CAAC;IAWzF,QAAQ,CACN,IAAI,EAAE,MAAM,EACZ,MAAM,CAAC,EAAE,sBAAsB,EAC/B,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,QAAQ,CAAC;CAQrB"}
1
+ {"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../../src/resources/templates.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAC5C,OAAO,KAAK,EACV,mBAAmB,EACnB,sBAAsB,EACtB,QAAQ,EACR,gBAAgB,EACjB,MAAM,aAAa,CAAA;AAEpB;;;;;GAKG;AACH,qBAAa,iBAAiB;IAE1B,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,MAAM;gBADN,IAAI,EAAE,UAAU,EAChB,MAAM,EAAE,MAAM;IAGjC,IAAI,CAAC,MAAM,CAAC,EAAE,mBAAmB,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,SAAS,CAAC,gBAAgB,CAAC;IAWzF,QAAQ,CACN,IAAI,EAAE,MAAM,EACZ,MAAM,CAAC,EAAE,sBAAsB,EAC/B,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,QAAQ,CAAC;IASpB;;;;;;;OAOG;IACH,IAAI,CAAC,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,kBAAkB,CAAC;CAQ5D;AAED,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,sBAAsB,CAAA;IAC9B,+CAA+C;IAC/C,MAAM,EAAE,MAAM,CAAA;IACd,yDAAyD;IACzD,OAAO,EAAE,MAAM,CAAA;IACf,6DAA6D;IAC7D,OAAO,EAAE,MAAM,CAAA;CAChB"}
@@ -26,5 +26,21 @@ export class TemplatesResource {
26
26
  ...(options ? { options } : {}),
27
27
  });
28
28
  }
29
+ /**
30
+ * Pull the latest template inventory from Meta and upsert into the
31
+ * Kirim DB for this WhatsApp account. Idempotent — call any time,
32
+ * returns a `{ created, updated, synced }` summary. Useful for
33
+ * platform integrations (multi-tenant Customers) so an automation
34
+ * can refresh templates after onboarding without waiting for the
35
+ * operator to click "Sync" in the dashboard.
36
+ */
37
+ sync(options) {
38
+ return this.http.requestData({
39
+ method: 'POST',
40
+ path: `${this.prefix}/templates/sync`,
41
+ body: {},
42
+ ...(options ? { options } : {}),
43
+ });
44
+ }
29
45
  }
30
46
  //# sourceMappingURL=templates.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"templates.js","sourceRoot":"","sources":["../../src/resources/templates.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAQ5C;;;;;GAKG;AACH,MAAM,OAAO,iBAAiB;IAET;IACA;IAFnB,YACmB,IAAgB,EAChB,MAAc;QADd,SAAI,GAAJ,IAAI,CAAY;QAChB,WAAM,GAAN,MAAM,CAAQ;IAC9B,CAAC;IAEJ,IAAI,CAAC,MAA4B,EAAE,OAAwB;QACzD,OAAO,IAAI,SAAS,CAClB,IAAI,CAAC,IAAI,EACT;YACE,IAAI,EAAE,GAAG,IAAI,CAAC,MAAM,YAAY;YAChC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,MAAsE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SACrG,EACD,OAAO,CACR,CAAA;IACH,CAAC;IAED,QAAQ,CACN,IAAY,EACZ,MAA+B,EAC/B,OAAwB;QAExB,OAAO,IAAI,CAAC,IAAI,CAAC,WAAW,CAAW;YACrC,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,GAAG,IAAI,CAAC,MAAM,cAAc,kBAAkB,CAAC,IAAI,CAAC,EAAE;YAC5D,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,MAAsE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YACpG,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAChC,CAAC,CAAA;IACJ,CAAC;CACF"}
1
+ {"version":3,"file":"templates.js","sourceRoot":"","sources":["../../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