@wats/graph 0.3.30 → 0.4.0-beta.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/dist/endpoints/flows/types.d.ts +2 -2
- package/dist/endpoints/media.d.ts +0 -11
- package/dist/endpoints/media.js +0 -17
- package/dist/endpoints/templates/advanced.d.ts +2 -2
- package/dist/errors.js +3 -4
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -6
- package/dist/subclients/wabaClient.d.ts +6 -6
- package/package.json +4 -2
|
@@ -78,8 +78,8 @@ export interface GetFlowAssetsInput {
|
|
|
78
78
|
* Canonical Flow metric names mirrored from pywa's `FlowMetricName` enum.
|
|
79
79
|
* Unknown values are preserved as raw strings (see {@link FlowMetric.name}).
|
|
80
80
|
*
|
|
81
|
-
* Reference:
|
|
82
|
-
* deprecated 2026-04-30; whether a replacement exists is
|
|
81
|
+
* Reference: Meta Flow Metrics API docs. The Metrics API is documented as
|
|
82
|
+
* deprecated 2026-04-30; whether a replacement exists is unverified.
|
|
83
83
|
*/
|
|
84
84
|
export declare const KNOWN_FLOW_METRIC_NAMES: readonly ["ENDPOINT_REQUEST_COUNT", "ENDPOINT_REQUEST_ERROR", "ENDPOINT_REQUEST_ERROR_RATE", "ENDPOINT_REQUEST_LATENCY_SECONDS_CEIL", "ENDPOINT_AVAILABILITY"];
|
|
85
85
|
export type FlowMetricName = (typeof KNOWN_FLOW_METRIC_NAMES)[number];
|
|
@@ -1,12 +1,5 @@
|
|
|
1
1
|
import type { GraphClient } from "../client.js";
|
|
2
2
|
export type MediaOperation = "upload" | "download" | "delete" | "download_bytes" | "decrypt_encrypted" | "create_upload_session" | "upload_file_to_session" | "get_upload_session";
|
|
3
|
-
export type MediaNotImplementedCode = "not_implemented";
|
|
4
|
-
export declare class MediaNotImplementedError extends Error {
|
|
5
|
-
readonly code: MediaNotImplementedCode;
|
|
6
|
-
readonly operation: MediaOperation;
|
|
7
|
-
readonly linearIssue: string;
|
|
8
|
-
constructor(operation: MediaOperation, linearIssue: string);
|
|
9
|
-
}
|
|
10
3
|
export type MediaValidationErrorCode = "invalid_client" | "invalid_params" | "invalid_options" | "invalid_url" | "invalid_phone_number_id" | "invalid_media_id" | "invalid_app_id" | "invalid_upload_session_id" | "invalid_upload_body" | "invalid_file" | "invalid_file_name" | "invalid_file_length" | "invalid_media_type" | "invalid_file_type" | "unsupported_media_type" | "invalid_messaging_product" | "upload_too_large" | "download_too_large" | "invalid_file_offset" | "invalid_content_length" | "invalid_response";
|
|
11
4
|
export declare class MediaValidationError extends Error {
|
|
12
5
|
readonly code: MediaValidationErrorCode;
|
|
@@ -107,10 +100,6 @@ export interface GetUploadSessionResponse {
|
|
|
107
100
|
readonly id: string;
|
|
108
101
|
readonly fileOffset: number;
|
|
109
102
|
}
|
|
110
|
-
export declare const MEDIA_LINEAR_ISSUE_UPLOAD = "WATS-37";
|
|
111
|
-
export declare const MEDIA_LINEAR_ISSUE_DOWNLOAD = "WATS-37";
|
|
112
|
-
export declare const MEDIA_LINEAR_ISSUE_DELETE = "WATS-37";
|
|
113
|
-
export declare const MEDIA_LINEAR_ISSUE_DECRYPT = "WATS-37";
|
|
114
103
|
export declare function uploadMedia(client: GraphClient, params: {
|
|
115
104
|
phoneNumberId: string;
|
|
116
105
|
}, body: MediaUploadBody, options?: MediaUploadOptions): Promise<MediaUploadResponse>;
|
package/dist/endpoints/media.js
CHANGED
|
@@ -1,18 +1,5 @@
|
|
|
1
1
|
import { createGraphApiError } from "../errors.js";
|
|
2
2
|
|
|
3
|
-
export class MediaNotImplementedError extends Error {
|
|
4
|
-
code;
|
|
5
|
-
operation;
|
|
6
|
-
linearIssue;
|
|
7
|
-
constructor(operation, linearIssue) {
|
|
8
|
-
super(`Media ${operation} is not implemented. Track implementation via Linear issue ${linearIssue}.`);
|
|
9
|
-
this.name = "MediaNotImplementedError";
|
|
10
|
-
this.code = "not_implemented";
|
|
11
|
-
this.operation = operation;
|
|
12
|
-
this.linearIssue = linearIssue;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
|
|
16
3
|
export class MediaValidationError extends Error {
|
|
17
4
|
code;
|
|
18
5
|
constructor(code, message, cause) {
|
|
@@ -65,10 +52,6 @@ const TYPED_ARRAY_PROTOTYPE = Object.getPrototypeOf(Uint8Array.prototype);
|
|
|
65
52
|
const TYPED_ARRAY_BUFFER_GETTER = Object.getOwnPropertyDescriptor(TYPED_ARRAY_PROTOTYPE, "buffer")?.get;
|
|
66
53
|
const TYPED_ARRAY_BYTE_LENGTH_GETTER = Object.getOwnPropertyDescriptor(TYPED_ARRAY_PROTOTYPE, "byteLength")?.get;
|
|
67
54
|
const TYPED_ARRAY_BYTE_OFFSET_GETTER = Object.getOwnPropertyDescriptor(TYPED_ARRAY_PROTOTYPE, "byteOffset")?.get;
|
|
68
|
-
export const MEDIA_LINEAR_ISSUE_UPLOAD = "WATS-37";
|
|
69
|
-
export const MEDIA_LINEAR_ISSUE_DOWNLOAD = "WATS-37";
|
|
70
|
-
export const MEDIA_LINEAR_ISSUE_DELETE = "WATS-37";
|
|
71
|
-
export const MEDIA_LINEAR_ISSUE_DECRYPT = "WATS-37";
|
|
72
55
|
const MAX_PATH_DECODE_ROUNDS = 5;
|
|
73
56
|
const SAFE_ID_REGEXP = /^[A-Za-z0-9_-]+$/;
|
|
74
57
|
const PHONE_NUMBER_ID_REGEXP = /^\d+$/;
|
|
@@ -171,7 +171,7 @@ export interface UnarchiveTemplatesResponse {
|
|
|
171
171
|
* {@link ARCHIVE_TEMPLATES_MAX_IDS} message templates on a WABA. Mirrors
|
|
172
172
|
* pywa's `WhatsApp.archive_templates`. Uses `GraphClient.requestRaw` (not
|
|
173
173
|
* `defineEndpoint`) because the endpoint lives on api.facebook.com, not
|
|
174
|
-
* graph.facebook.com. See
|
|
174
|
+
* graph.facebook.com. See maintainers/template-management-reference.md §5.
|
|
175
175
|
*/
|
|
176
176
|
export declare function archiveTemplates(client: GraphClient, params: ArchiveTemplatesInput, _body?: never, opts?: EndpointInvokeOptions): Promise<ArchiveTemplatesResponse>;
|
|
177
177
|
/**
|
|
@@ -180,7 +180,7 @@ export declare function archiveTemplates(client: GraphClient, params: ArchiveTem
|
|
|
180
180
|
* {@link ARCHIVE_TEMPLATES_MAX_IDS} message templates on a WABA. Mirrors
|
|
181
181
|
* pywa's `WhatsApp.unarchive_templates`. Uses `GraphClient.requestRaw` (not
|
|
182
182
|
* `defineEndpoint`) because the endpoint lives on api.facebook.com, not
|
|
183
|
-
* graph.facebook.com. See
|
|
183
|
+
* graph.facebook.com. See maintainers/template-management-reference.md §5.
|
|
184
184
|
*/
|
|
185
185
|
export declare function unarchiveTemplates(client: GraphClient, params: UnarchiveTemplatesInput, _body?: never, opts?: EndpointInvokeOptions): Promise<UnarchiveTemplatesResponse>;
|
|
186
186
|
/** Finite cap on the number of languages per upsert call (defensive bound). */
|
package/dist/errors.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { isRecord } from "@wats/internal-utils";
|
|
2
|
+
|
|
1
3
|
export class GraphApiError extends Error {
|
|
2
4
|
status;
|
|
3
5
|
type;
|
|
@@ -112,9 +114,6 @@ export class GraphSerializationError extends GraphApiError {
|
|
|
112
114
|
this.cause = cause;
|
|
113
115
|
}
|
|
114
116
|
}
|
|
115
|
-
function isRecord(value) {
|
|
116
|
-
return typeof value === "object" && value !== null;
|
|
117
|
-
}
|
|
118
117
|
export function isGraphApiErrorPayload(value) {
|
|
119
118
|
if (!isRecord(value) || Array.isArray(value)) {
|
|
120
119
|
return false;
|
|
@@ -178,7 +177,7 @@ function isRateLimitClassification(status, payload) {
|
|
|
178
177
|
}
|
|
179
178
|
return false;
|
|
180
179
|
}
|
|
181
|
-
const BEARER_TOKEN_REGEXP = /
|
|
180
|
+
const BEARER_TOKEN_REGEXP = /Bearer\s+\S+/g;
|
|
182
181
|
function redactString(value) {
|
|
183
182
|
return value.replace(BEARER_TOKEN_REGEXP, "Bearer ***");
|
|
184
183
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -22,5 +22,5 @@ export { createFetchTransport } from "./createFetchTransport.js";
|
|
|
22
22
|
export type { CreateFetchTransportOptions } from "./createFetchTransport.js";
|
|
23
23
|
export { paginate, paginateAll, PaginationError } from "./pagination.js";
|
|
24
24
|
export type { PaginationOptions, PaginatedResult, PaginatedPage, PaginationErrorCode } from "./pagination.js";
|
|
25
|
-
export { uploadMedia, downloadMedia, deleteMedia, downloadMediaBytes, decryptEncryptedMedia, createUploadSession, uploadFileToSession, getUploadSession,
|
|
26
|
-
export type { MediaOperation,
|
|
25
|
+
export { uploadMedia, downloadMedia, deleteMedia, downloadMediaBytes, decryptEncryptedMedia, createUploadSession, uploadFileToSession, getUploadSession, MediaValidationError, MediaCryptoError, MediaIntegrityError, DEFAULT_MAX_MEDIA_UPLOAD_BYTES, MAX_MEDIA_UPLOAD_BYTES, DEFAULT_MAX_MEDIA_DOWNLOAD_BYTES, MAX_MEDIA_DOWNLOAD_BYTES, DEFAULT_MAX_UPLOAD_SESSION_BYTES, MAX_UPLOAD_SESSION_BYTES } from "./endpoints/media.js";
|
|
26
|
+
export type { MediaOperation, MediaValidationErrorCode, MediaCryptoErrorCode, MediaIntegrityErrorCode, MediaUploadBody, MediaUploadOptions, MediaUploadResponse, MediaDownloadOptions, MediaDownloadResponse, MediaDeleteOptions, MediaDeleteResponse, MediaDownloadBytesOptions, MediaDownloadBytesResponse, EncryptedMediaBundle, CreateUploadSessionParams, UploadSessionOptions, CreateUploadSessionResponse, UploadFileToSessionParams, UploadFileToSessionResponse, GetUploadSessionParams, GetUploadSessionResponse } from "./endpoints/media.js";
|
package/dist/index.js
CHANGED
|
@@ -39,7 +39,6 @@ export {
|
|
|
39
39
|
createUploadSession,
|
|
40
40
|
uploadFileToSession,
|
|
41
41
|
getUploadSession,
|
|
42
|
-
MediaNotImplementedError,
|
|
43
42
|
MediaValidationError,
|
|
44
43
|
MediaCryptoError,
|
|
45
44
|
MediaIntegrityError,
|
|
@@ -48,9 +47,5 @@ export {
|
|
|
48
47
|
DEFAULT_MAX_MEDIA_DOWNLOAD_BYTES,
|
|
49
48
|
MAX_MEDIA_DOWNLOAD_BYTES,
|
|
50
49
|
DEFAULT_MAX_UPLOAD_SESSION_BYTES,
|
|
51
|
-
MAX_UPLOAD_SESSION_BYTES
|
|
52
|
-
MEDIA_LINEAR_ISSUE_UPLOAD,
|
|
53
|
-
MEDIA_LINEAR_ISSUE_DOWNLOAD,
|
|
54
|
-
MEDIA_LINEAR_ISSUE_DELETE,
|
|
55
|
-
MEDIA_LINEAR_ISSUE_DECRYPT
|
|
50
|
+
MAX_UPLOAD_SESSION_BYTES
|
|
56
51
|
} from "./endpoints/media.js";
|
|
@@ -73,7 +73,7 @@ export declare class WABAClient {
|
|
|
73
73
|
* Graph `POST /{templateId}/unpause` (WATS-153). Template-id scoped edge
|
|
74
74
|
* that unpauses a paused template. Delegates to the endpoint-registry
|
|
75
75
|
* callable; the bound wabaId is not used (mirrors getMessageTemplate).
|
|
76
|
-
* The endpoint/response shape is UNVERIFIED — see
|
|
76
|
+
* The endpoint/response shape is UNVERIFIED — see maintainers/template-management-reference.md.
|
|
77
77
|
*/
|
|
78
78
|
unpauseTemplate(params: UnpauseTemplateInput, opts?: EndpointInvokeOptions): Promise<TemplateUnpauseResult>;
|
|
79
79
|
/**
|
|
@@ -82,7 +82,7 @@ export declare class WABAClient {
|
|
|
82
82
|
* into the bound destination WABA. Mirrors pywa's
|
|
83
83
|
* `WhatsApp.migrate_templates`. The bound wabaId is used as the
|
|
84
84
|
* destination and wins over any caller-supplied `destinationWabaId`
|
|
85
|
-
* (mirrors `migrateFlows`).
|
|
85
|
+
* (mirrors `migrateFlows`).
|
|
86
86
|
*/
|
|
87
87
|
migrateTemplates(params: Omit<MigrateTemplatesInput, "destinationWabaId">, opts?: EndpointInvokeOptions): Promise<MigrateTemplatesResponse>;
|
|
88
88
|
/**
|
|
@@ -92,7 +92,7 @@ export declare class WABAClient {
|
|
|
92
92
|
* `GraphClient.requestRaw` (not `defineEndpoint`) because the endpoint
|
|
93
93
|
* lives on api.facebook.com, not graph.facebook.com. The bound wabaId is
|
|
94
94
|
* used in the path and wins over any caller-supplied `wabaId` (mirrors
|
|
95
|
-
* `migrateTemplates`). See
|
|
95
|
+
* `migrateTemplates`). See maintainers/template-management-reference.md §5.
|
|
96
96
|
*/
|
|
97
97
|
archiveTemplates(params: Omit<ArchiveTemplatesInput, "wabaId">, opts?: EndpointInvokeOptions): Promise<ArchiveTemplatesResponse>;
|
|
98
98
|
/**
|
|
@@ -102,7 +102,7 @@ export declare class WABAClient {
|
|
|
102
102
|
* `GraphClient.requestRaw` (not `defineEndpoint`) because the endpoint
|
|
103
103
|
* lives on api.facebook.com, not graph.facebook.com. The bound wabaId is
|
|
104
104
|
* used in the path and wins over any caller-supplied `wabaId` (mirrors
|
|
105
|
-
* `migrateTemplates`). See
|
|
105
|
+
* `migrateTemplates`). See maintainers/template-management-reference.md §5.
|
|
106
106
|
*/
|
|
107
107
|
unarchiveTemplates(params: Omit<UnarchiveTemplatesInput, "wabaId">, opts?: EndpointInvokeOptions): Promise<UnarchiveTemplatesResponse>;
|
|
108
108
|
/**
|
|
@@ -147,14 +147,14 @@ export declare class WABAClient {
|
|
|
147
147
|
* Graph `GET /{flowId}?fields=metric.name(...).granularity(...)...`
|
|
148
148
|
* (WATS-154). Flow-id scoped edge that returns Flow metrics; the bound
|
|
149
149
|
* wabaId is not used because the path is flow-id scoped (mirrors
|
|
150
|
-
* getFlow / getFlowAssets).
|
|
150
|
+
* getFlow / getFlowAssets).
|
|
151
151
|
*/
|
|
152
152
|
getFlowMetrics(params: GetFlowMetricsInput, opts?: EndpointInvokeOptions): Promise<FlowMetric>;
|
|
153
153
|
/**
|
|
154
154
|
* Graph `POST /{wabaId}/migrate_flows?source_waba_id=...&source_flow_names=...`
|
|
155
155
|
* (WATS-154). Copies (not moves) Flows from a source WABA into the bound
|
|
156
156
|
* destination WABA. Mirrors pywa's `WhatsApp.migrate_flows`. The bound
|
|
157
|
-
* wabaId is used as the destination
|
|
157
|
+
* wabaId is used as the destination.
|
|
158
158
|
*/
|
|
159
159
|
migrateFlows(params: Omit<MigrateFlowsInput, "destinationWabaId">, opts?: EndpointInvokeOptions): Promise<MigrateFlowsResponse>;
|
|
160
160
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wats/graph",
|
|
3
|
-
"
|
|
3
|
+
"description": "Graph client, transport, endpoints, errors, pagination.",
|
|
4
|
+
"version": "0.4.0-beta.0",
|
|
4
5
|
"private": false,
|
|
5
6
|
"license": "MIT",
|
|
6
7
|
"type": "module",
|
|
@@ -85,6 +86,7 @@
|
|
|
85
86
|
"wats"
|
|
86
87
|
],
|
|
87
88
|
"dependencies": {
|
|
88
|
-
"@wats/crypto": "^0.
|
|
89
|
+
"@wats/crypto": "^0.4.0-beta.0",
|
|
90
|
+
"@wats/internal-utils": "^0.4.0-beta.0"
|
|
89
91
|
}
|
|
90
92
|
}
|