@open-wa/schema 5.0.0-alpha.0 → 5.0.0-alpha.3

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.
Files changed (102) hide show
  1. package/dist/generated/index.cjs +598 -0
  2. package/dist/generated/index.cjs.map +1 -0
  3. package/dist/generated/index.d.cts +3674 -0
  4. package/dist/generated/index.d.cts.map +1 -0
  5. package/dist/generated/index.d.mts +3674 -0
  6. package/dist/generated/index.d.mts.map +1 -0
  7. package/dist/generated/index.mjs +595 -0
  8. package/dist/generated/index.mjs.map +1 -0
  9. package/dist/http-manifest-BlJWPKsp.d.mts +177 -0
  10. package/dist/http-manifest-BlJWPKsp.d.mts.map +1 -0
  11. package/dist/http-manifest-DCOVY9QZ.d.cts +177 -0
  12. package/dist/http-manifest-DCOVY9QZ.d.cts.map +1 -0
  13. package/dist/http-manifest.cjs +59 -0
  14. package/dist/http-manifest.cjs.map +1 -0
  15. package/dist/http-manifest.d.cts +2 -0
  16. package/dist/http-manifest.d.mts +2 -0
  17. package/dist/http-manifest.mjs +58 -0
  18. package/dist/http-manifest.mjs.map +1 -0
  19. package/dist/implementor-DIBNbQXA.d.cts +8 -0
  20. package/dist/implementor-DIBNbQXA.d.cts.map +1 -0
  21. package/dist/implementor-DoN9ga7C.d.mts +8 -0
  22. package/dist/implementor-DoN9ga7C.d.mts.map +1 -0
  23. package/dist/implementor.cjs +50 -0
  24. package/dist/implementor.cjs.map +1 -0
  25. package/dist/implementor.d.cts +2 -0
  26. package/dist/implementor.d.mts +2 -0
  27. package/dist/implementor.mjs +48 -0
  28. package/dist/implementor.mjs.map +1 -0
  29. package/dist/index-BB9uyLe8.d.cts +1323 -0
  30. package/dist/index-BB9uyLe8.d.cts.map +1 -0
  31. package/dist/index-D77q1gPk.d.mts +1323 -0
  32. package/dist/index-D77q1gPk.d.mts.map +1 -0
  33. package/dist/index.cjs +649 -0
  34. package/dist/index.cjs.map +1 -0
  35. package/dist/index.d.cts +4 -0
  36. package/dist/index.d.mts +4 -0
  37. package/dist/index.mjs +299 -0
  38. package/dist/index.mjs.map +1 -0
  39. package/dist/methods/index.cjs +125 -0
  40. package/dist/methods/index.d.cts +2 -0
  41. package/dist/methods/index.d.mts +2 -0
  42. package/dist/methods/index.mjs +2 -0
  43. package/dist/methods-BXZrkKjP.mjs +2633 -0
  44. package/dist/methods-BXZrkKjP.mjs.map +1 -0
  45. package/dist/methods-CuiwUO7-.cjs +3802 -0
  46. package/dist/methods-CuiwUO7-.cjs.map +1 -0
  47. package/dist/registry-CsyR8i6y.mjs +284 -0
  48. package/dist/registry-CsyR8i6y.mjs.map +1 -0
  49. package/dist/registry-TbMVoiw5.cjs +355 -0
  50. package/dist/registry-TbMVoiw5.cjs.map +1 -0
  51. package/package.json +6 -3
  52. package/CHANGELOG.md +0 -23
  53. package/client_migration_doc.md +0 -467
  54. package/codecs_and_params_plan.md +0 -936
  55. package/migration_plan_doc.md +0 -223
  56. package/scripts/gen-client-implementation.ts +0 -129
  57. package/scripts/gen-client-reference-docs.ts +0 -621
  58. package/scripts/gen-openapi.ts +0 -96
  59. package/scripts/gen-types.ts +0 -43
  60. package/scripts/verify-v5-pipeline.ts +0 -85
  61. package/src/__tests__/generators.contract.test.ts +0 -181
  62. package/src/__tests__/registry.contract.test.ts +0 -81
  63. package/src/client-config.ts +0 -30
  64. package/src/codecs.test.ts +0 -41
  65. package/src/codecs.ts +0 -191
  66. package/src/common-types.ts +0 -280
  67. package/src/config.ts +0 -47
  68. package/src/enums.ts +0 -63
  69. package/src/events/groups.ts +0 -33
  70. package/src/events/index.ts +0 -4
  71. package/src/events/messaging.ts +0 -72
  72. package/src/events/registry.ts +0 -114
  73. package/src/events/state.ts +0 -59
  74. package/src/generated/AliasMap.ts +0 -214
  75. package/src/generated/BaseClient.ts +0 -868
  76. package/src/generated/BaseNamespacedClient.ts +0 -212
  77. package/src/generated/index.ts +0 -5
  78. package/src/generated/openapi.json +0 -7799
  79. package/src/generated/types.ts +0 -377
  80. package/src/http-manifest.ts +0 -97
  81. package/src/implementor.test.ts +0 -88
  82. package/src/implementor.ts +0 -75
  83. package/src/index.ts +0 -43
  84. package/src/methods/business.ts +0 -51
  85. package/src/methods/chats.ts +0 -263
  86. package/src/methods/communities.ts +0 -119
  87. package/src/methods/contacts.ts +0 -158
  88. package/src/methods/groups.ts +0 -376
  89. package/src/methods/index.ts +0 -33
  90. package/src/methods/labels.ts +0 -86
  91. package/src/methods/media.ts +0 -36
  92. package/src/methods/messaging.ts +0 -828
  93. package/src/methods/session.ts +0 -261
  94. package/src/methods/status.ts +0 -120
  95. package/src/open-wa-utils.d.ts +0 -4
  96. package/src/parameters.ts +0 -237
  97. package/src/registry.test.ts +0 -30
  98. package/src/registry.ts +0 -601
  99. package/tsconfig.generated.json +0 -11
  100. package/tsconfig.json +0 -15
  101. package/tsdown.config.ts +0 -16
  102. package/vitest.config.ts +0 -10
@@ -1,96 +0,0 @@
1
- import fs from 'fs';
2
- import path from 'path';
3
- import { fileURLToPath } from 'node:url';
4
- import { getHttpMethodDefinitions } from '../src/http-manifest';
5
- import '../src/methods';
6
-
7
- const generatedDir = path.join(fileURLToPath(new URL('.', import.meta.url)), '../src/generated');
8
- if (!fs.existsSync(generatedDir)) {
9
- fs.mkdirSync(generatedDir, { recursive: true });
10
- }
11
-
12
- function schemaToOpenApi(schema: { toJSONSchema?: (params?: unknown) => unknown }) {
13
- if (typeof schema?.toJSONSchema === 'function') {
14
- return schema.toJSONSchema({ target: 'openapi-3.0' });
15
- }
16
-
17
- return { type: 'object', additionalProperties: true };
18
- }
19
-
20
- function buildQueryParameters(def: ReturnType<typeof getHttpMethodDefinitions>[number]) {
21
- const inputSchema = schemaToOpenApi(def.inputSchema) as {
22
- properties?: Record<string, Record<string, unknown>>;
23
- required?: string[];
24
- };
25
- const properties = inputSchema.properties ?? {};
26
- const required = new Set(inputSchema.required ?? []);
27
-
28
- return def.parameterOrder.map((name) => ({
29
- name,
30
- in: 'query',
31
- required: required.has(name),
32
- description: properties[name]?.description || `Argument: ${name}`,
33
- schema: properties[name] || { type: 'string' },
34
- }));
35
- }
36
-
37
- const methods = getHttpMethodDefinitions();
38
-
39
- const document = {
40
- openapi: '3.0.3',
41
- info: {
42
- title: 'Open WA API',
43
- version: '5.0.0',
44
- description: 'API definition for Open WA v5',
45
- },
46
- servers: [
47
- {
48
- url: 'http://localhost:8080',
49
- },
50
- ],
51
- paths: methods.reduce<Record<string, any>>((paths, def) => {
52
- paths[def.path] = {
53
- [def.httpMethod.toLowerCase()]: {
54
- tags: [def.namespace],
55
- operationId: def.functionName,
56
- summary: def.description,
57
- description: def.description,
58
- ...(def.httpMethod === 'GET' || def.httpMethod === 'DELETE'
59
- ? { parameters: buildQueryParameters(def) }
60
- : {
61
- requestBody: {
62
- required: def.parameterOrder.length > 0,
63
- content: {
64
- 'application/json': {
65
- schema: schemaToOpenApi(def.inputSchema),
66
- },
67
- },
68
- },
69
- }),
70
- 'x-openwa-aliases': def.routeSignatures.filter((signature) => signature !== `${def.httpMethod} ${def.path}`),
71
- responses: {
72
- 200: {
73
- description: 'Successful response',
74
- content: {
75
- 'application/json': {
76
- schema: schemaToOpenApi(def.outputSchema),
77
- },
78
- },
79
- },
80
- 400: {
81
- description: 'Validation error',
82
- },
83
- 500: {
84
- description: 'Internal server error',
85
- },
86
- },
87
- },
88
- };
89
-
90
- return paths;
91
- }, {}),
92
- };
93
-
94
- fs.writeFileSync(path.join(generatedDir, 'openapi.json'), JSON.stringify(document, null, 2));
95
-
96
- console.log(`Successfully generated openapi.json with ${methods.length} methods`);
@@ -1,43 +0,0 @@
1
- import fs from 'fs';
2
- import path from 'path';
3
- import { clientRegistry } from '../src/registry';
4
- import '../src/methods'; // Ensure methods are registered
5
-
6
- // Create generated directory
7
- import { fileURLToPath } from "node:url";
8
- const generatedDir = path.join(fileURLToPath(new URL(".", import.meta.url)), '../src/generated');
9
- if (!fs.existsSync(generatedDir)) {
10
- fs.mkdirSync(generatedDir, { recursive: true });
11
- }
12
-
13
- let output = `/* eslint-disable */
14
- /**
15
- * This file was automatically generated by packages/schema/scripts/gen-types.ts
16
- * Do not edit this file manually.
17
- */
18
-
19
- import type * as Zod from 'zod';
20
- import type * as Methods from '../methods';
21
- `;
22
-
23
- // Generate types for all methods
24
- const methods = clientRegistry.getAll();
25
-
26
- methods.forEach((method) => {
27
- const name = method.meta.functionName;
28
- const inputIdentifier = `${capitalize(name)}Input`;
29
- const outputIdentifier = `${capitalize(name)}Output`;
30
-
31
- output += `
32
- export type ${inputIdentifier} = Zod.input<typeof Methods.${name}.openWAInput>;
33
- export type ${outputIdentifier} = Zod.output<typeof Methods.${name}.openWAOutput>;
34
- `;
35
- });
36
-
37
- // Write types.ts
38
- fs.writeFileSync(path.join(generatedDir, 'types.ts'), output);
39
- console.log('Successfully generated types.ts');
40
-
41
- function capitalize(s: string) {
42
- return s.charAt(0).toUpperCase() + s.slice(1);
43
- }
@@ -1,85 +0,0 @@
1
- #!/usr/bin/env ts-node
2
- /**
3
- * E2E verification script for v5 schema-first pipeline
4
- * Run with: ts-node scripts/verify-v5-pipeline.ts
5
- */
6
-
7
- import { clientRegistry } from '../src/registry';
8
- import '../src/methods';
9
- import fs from 'fs';
10
- import path from 'path';
11
-
12
- console.log('🔍 Verifying v5 Schema-First Pipeline...\n');
13
-
14
- let passed = 0;
15
- let failed = 0;
16
-
17
- function check(name: string, condition: boolean, message?: string) {
18
- if (condition) {
19
- console.log(` ✅ ${name}`);
20
- passed++;
21
- } else {
22
- console.log(` ❌ ${name}${message ? `: ${message}` : ''}`);
23
- failed++;
24
- }
25
- }
26
-
27
- console.log('📦 Registry Checks:');
28
- const methods = clientRegistry.getAll();
29
- check('Methods registered', methods.length > 100, `Found ${methods.length}`);
30
- check('sendText exists', clientRegistry.has('sendText'));
31
- check('getChat exists', clientRegistry.has('getChat'));
32
- check('getMe exists', clientRegistry.has('getMe'));
33
-
34
- let metaComplete = true;
35
- methods.forEach((def) => {
36
- if (!def.meta.functionName || !def.meta.inputSchema) {
37
- metaComplete = false;
38
- }
39
- });
40
- check('All methods have complete metadata', metaComplete);
41
-
42
- console.log('\n📄 Generated Files:');
43
- import { fileURLToPath } from "node:url";
44
- const generatedDir = path.join(fileURLToPath(new URL(".", import.meta.url)), '../src/generated');
45
-
46
- const openApiPath = path.join(generatedDir, 'openapi.json');
47
- check('openapi.json exists', fs.existsSync(openApiPath));
48
-
49
- if (fs.existsSync(openApiPath)) {
50
- try {
51
- JSON.parse(fs.readFileSync(openApiPath, 'utf-8'));
52
- check('openapi.json is valid JSON', true);
53
- } catch (e) {
54
- check('openapi.json is valid JSON', false, (e as Error).message);
55
- }
56
- }
57
-
58
- const typesPath = path.join(generatedDir, 'types.ts');
59
- check('types.ts exists', fs.existsSync(typesPath));
60
-
61
- const baseClientPath = path.join(generatedDir, 'BaseClient.ts');
62
- check('BaseClient.ts exists', fs.existsSync(baseClientPath));
63
-
64
- console.log('\n🏷️ Namespace Distribution:');
65
- const namespaces = new Map<string, number>();
66
- methods.forEach((def) => {
67
- const ns = def.meta.namespace || 'core';
68
- namespaces.set(ns, (namespaces.get(ns) || 0) + 1);
69
- });
70
- namespaces.forEach((count, ns) => {
71
- console.log(` 📁 ${ns}: ${count} methods`);
72
- });
73
-
74
- console.log('\n📊 Summary:');
75
- console.log(` Total methods: ${methods.length}`);
76
- console.log(` Passed checks: ${passed}`);
77
- console.log(` Failed checks: ${failed}`);
78
-
79
- if (failed > 0) {
80
- console.log('\n❌ Pipeline verification FAILED');
81
- process.exit(1);
82
- } else {
83
- console.log('\n✅ Pipeline verification PASSED');
84
- process.exit(0);
85
- }
@@ -1,181 +0,0 @@
1
- import fs from 'fs';
2
- import path from 'path';
3
- import { execFile } from 'node:child_process';
4
- import { promisify } from 'node:util';
5
- import { clientRegistry } from '../registry';
6
- import '../methods';
7
-
8
- const generatedDir = path.join(__dirname, '../generated');
9
- const clientDocsDir = path.join(__dirname, '../../../../apps/docs/content/docs/reference/client');
10
- const execFileAsync = promisify(execFile);
11
-
12
- describe('generator outputs', () => {
13
- describe('openapi.json', () => {
14
- const openapiPath = path.join(generatedDir, 'openapi.json');
15
-
16
- it('should exist', () => {
17
- expect(fs.existsSync(openapiPath)).toBe(true);
18
- });
19
-
20
- it('should be valid JSON', () => {
21
- const content = fs.readFileSync(openapiPath, 'utf-8');
22
- expect(() => JSON.parse(content)).not.toThrow();
23
- });
24
-
25
- it('should have paths for registered methods', () => {
26
- const content = JSON.parse(fs.readFileSync(openapiPath, 'utf-8'));
27
- const pathCount = Object.keys(content.paths || {}).length;
28
- const methodCount = clientRegistry.getAll().length;
29
-
30
- expect(pathCount).toBeGreaterThan(methodCount * 0.9);
31
- });
32
-
33
- it('should have valid OpenAPI structure', () => {
34
- const content = JSON.parse(fs.readFileSync(openapiPath, 'utf-8'));
35
-
36
- expect(content.openapi).toBe('3.0.3');
37
- expect(content.info).toBeDefined();
38
- expect(content.info.title).toBeTruthy();
39
- expect(content.paths).toBeDefined();
40
- });
41
- });
42
-
43
- describe('types.ts', () => {
44
- const typesPath = path.join(generatedDir, 'types.ts');
45
-
46
- it('should exist', () => {
47
- expect(fs.existsSync(typesPath)).toBe(true);
48
- });
49
-
50
- it('should have type exports for methods', () => {
51
- const content = fs.readFileSync(typesPath, 'utf-8');
52
-
53
- expect(content).toContain('SendTextInput');
54
- expect(content).toContain('SendTextOutput');
55
- expect(content).toContain('export type');
56
- });
57
-
58
- it.skip('should not have TypeScript errors', async () => {
59
- if (!process.env.TS_CHECK) {
60
- return;
61
- }
62
-
63
- await expect(execFileAsync('npx', ['tsc', '--noEmit', typesPath])).resolves.toBeDefined();
64
- });
65
- });
66
-
67
- describe('BaseClient.ts', () => {
68
- const baseClientPath = path.join(generatedDir, 'BaseClient.ts');
69
- const generatedIndexPath = path.join(generatedDir, 'index.ts');
70
-
71
- it('should exist', () => {
72
- expect(fs.existsSync(baseClientPath)).toBe(true);
73
- });
74
-
75
- it('should have method implementations', () => {
76
- const content = fs.readFileSync(baseClientPath, 'utf-8');
77
-
78
- expect(content).toContain('sendText = implementMethod');
79
- expect(content).toContain('public sendText');
80
- });
81
-
82
- it('should have at least expected method count', () => {
83
- const content = fs.readFileSync(baseClientPath, 'utf-8');
84
- const methodCount = clientRegistry.getAll().length;
85
-
86
- const matches = content.match(/implementMethod/g) || [];
87
- expect(matches.length).toBeGreaterThanOrEqual(methodCount);
88
- });
89
-
90
- it('should create a generated package index', () => {
91
- expect(fs.existsSync(generatedIndexPath)).toBe(true);
92
- const content = fs.readFileSync(generatedIndexPath, 'utf-8');
93
- expect(content).toContain("export * from './BaseClient'");
94
- expect(content).toContain("export * from './types'");
95
- });
96
- });
97
-
98
- describe('Client API reference docs', () => {
99
- const indexPath = path.join(clientDocsDir, 'index.mdx');
100
- const metaPath = path.join(clientDocsDir, 'meta.json');
101
- const messagesPath = path.join(clientDocsDir, 'messages.mdx');
102
-
103
- it('should create client docs index and navigation metadata', () => {
104
- expect(fs.existsSync(indexPath)).toBe(true);
105
- expect(fs.existsSync(metaPath)).toBe(true);
106
-
107
- const indexContent = fs.readFileSync(indexPath, 'utf-8');
108
- const meta = JSON.parse(fs.readFileSync(metaPath, 'utf-8'));
109
-
110
- expect(indexContent).toContain('Generated file warning');
111
- expect(indexContent).toContain('packages/schema/scripts/gen-client-reference-docs.ts');
112
- expect(indexContent).toContain('<Cards>');
113
- expect(indexContent).toContain('<Card title="Messages" href="./messages">');
114
- expect(indexContent).toContain('client methods');
115
- expect(meta.title).toBe('Client API');
116
- expect(meta.icon).toBe('BookOpen');
117
- expect(meta.pages).toContain('messages');
118
- });
119
-
120
- it('should create one generated MDX page per namespace', () => {
121
- const namespaces = Array.from(new Set(clientRegistry.getAll().map((def) => def.meta.namespace || 'core'))).sort();
122
- const mdxFiles = fs
123
- .readdirSync(clientDocsDir)
124
- .filter((fileName) => fileName.endsWith('.mdx') && fileName !== 'index.mdx' && fileName !== 'client.mdx')
125
- .sort();
126
-
127
- expect(mdxFiles).toEqual(namespaces.map((namespace) => `${namespace.toLowerCase()}.mdx`));
128
- });
129
-
130
- it('should include sendText method details from the schema registry', () => {
131
- expect(fs.existsSync(messagesPath)).toBe(true);
132
- const content = fs.readFileSync(messagesPath, 'utf-8');
133
-
134
- expect(content).toContain('Generated file warning');
135
- expect(content).toContain('packages/schema/scripts/gen-client-reference-docs.ts');
136
- expect(content).toContain('## `sendText`');
137
- expect(content).toContain('### Overview');
138
- expect(content).toContain('| Prop | Value |');
139
- expect(content).toContain('| Namespace | `messages` |');
140
- expect(content).toContain('| Action | `send` |');
141
- expect(content).toContain('| Positional parameter order | `to`, `content`, `options` |');
142
- expect(content).toContain('| Aliases | `messages.sendText` |');
143
- expect(content).toContain('### Routes');
144
- expect(content).toContain('| Type | Method | Path | Name | Status |');
145
- expect(content).toContain('| Primary | `POST` | `/api/messages/sendText` | `sendText` | Active |');
146
- expect(content).toContain('| Alias | `POST` | `/api/sendText` | `sendText` | Active |');
147
- expect(content).toContain('### Usage');
148
- expect(content).toContain('<Tabs items={["Client", "Namespaced client", "HTTP API"]}>');
149
- expect(content).toContain('<Tab value="Client">');
150
- expect(content).toContain('const result = await client.sendText({');
151
- expect(content).toContain('<Tab value="Namespaced client">');
152
- expect(content).toContain('const result = await client.messages.sendText({');
153
- expect(content).toContain('<Tab value="HTTP API">');
154
- expect(content).toContain('curl -X POST "http://localhost:8080/api/messages/sendText"');
155
- expect(content).toContain('### Parameters');
156
- expect(content).toContain('<AutoTypeTable path="./generated-method-params.ts" name="SendTextParams" />');
157
- expect(content).toContain('### Output');
158
- expect(content).toContain('| Return type | `object &#123; _serialized &#125; \\| boolean \\| string` |');
159
- expect(content).not.toContain('Returns: `');
160
- });
161
-
162
- it('should render licensed methods with callouts and visible heading indicators', () => {
163
- expect(fs.existsSync(messagesPath)).toBe(true);
164
- const content = fs.readFileSync(messagesPath, 'utf-8');
165
-
166
- expect(content).toContain('## `sendButtons` - insiders');
167
- expect(content).toContain('<LicensedFeatureCallout tier="insiders" />');
168
- expect(content).toContain('| License | `insiders` |');
169
- });
170
-
171
- it('should visibly label deprecated alias routes in route tables', () => {
172
- const contactsPath = path.join(clientDocsDir, 'contacts.mdx');
173
- expect(fs.existsSync(contactsPath)).toBe(true);
174
- const content = fs.readFileSync(contactsPath, 'utf-8');
175
-
176
- expect(content).toContain('## `blockContact`');
177
- expect(content).toContain('| Deprecated alias | `PUT` | `/api/contactBlock` | `contactBlock` | **Deprecated** |');
178
- expect(content).toContain('| Deprecated alias | `PUT` | `/api/contacts/contactBlock` | `contacts.contactBlock` | **Deprecated** |');
179
- });
180
- });
181
- });
@@ -1,81 +0,0 @@
1
- import { clientRegistry } from '../registry';
2
- import '../methods'; // Trigger registration
3
-
4
- describe('clientRegistry contract', () => {
5
- describe('registration', () => {
6
- it('should have registered methods', () => {
7
- const methods = clientRegistry.getAll();
8
- expect(methods.length).toBeGreaterThan(100); // We have 121 methods
9
- });
10
-
11
- it('should have unique method names', () => {
12
- const names = clientRegistry.getNames();
13
- const uniqueNames = new Set(names);
14
- expect(uniqueNames.size).toBe(names.length);
15
- });
16
-
17
- it('should have required metadata for each method', () => {
18
- const methods = clientRegistry.getAll();
19
-
20
- methods.forEach((def) => {
21
- expect(def.meta.functionName).toBeTruthy();
22
- expect(def.meta.parameterOrder).toBeInstanceOf(Array);
23
- expect(def.meta.inputSchema).toBeDefined();
24
- expect(def.meta.outputSchema).toBeDefined();
25
- });
26
- });
27
- });
28
-
29
- describe('lookup', () => {
30
- it('should find method by name', () => {
31
- const sendText = clientRegistry.get('sendText');
32
- expect(sendText).toBeDefined();
33
- expect(sendText?.meta.functionName).toBe('sendText');
34
- });
35
-
36
- it('should find method by schema', () => {
37
- const sendTextDef = clientRegistry.get('sendText');
38
- expect(sendTextDef).toBeDefined();
39
-
40
- const foundBySchema = clientRegistry.getBySchema(sendTextDef!.schema);
41
- expect(foundBySchema?.meta.functionName).toBe('sendText');
42
- });
43
-
44
- it('should return undefined for non-existent method', () => {
45
- const notFound = clientRegistry.get('thisMethodDoesNotExist');
46
- expect(notFound).toBeUndefined();
47
- });
48
- });
49
-
50
- describe('namespaces', () => {
51
- it('should have methods in messaging namespace', () => {
52
- const messagingMethods = clientRegistry.getByNamespace('messages');
53
- expect(messagingMethods.length).toBeGreaterThan(0);
54
- });
55
-
56
- it('should have methods in chats namespace', () => {
57
- const chatMethods = clientRegistry.getByNamespace('chats');
58
- expect(chatMethods.length).toBeGreaterThan(0);
59
- });
60
- });
61
-
62
- describe('critical methods exist', () => {
63
- const criticalMethods = [
64
- 'sendText',
65
- 'sendImage',
66
- 'sendFile',
67
- 'getChat',
68
- 'getAllChats',
69
- 'getContact',
70
- 'getAllContacts',
71
- 'getMe',
72
- 'getConnectionState',
73
- ];
74
-
75
- criticalMethods.forEach((name) => {
76
- it(`should have ${name} registered`, () => {
77
- expect(clientRegistry.has(name)).toBe(true);
78
- });
79
- });
80
- });
81
- });
@@ -1,30 +0,0 @@
1
- /**
2
- * Client configuration types - re-exported from @open-wa/config
3
- *
4
- * @deprecated Import from '@open-wa/config' instead
5
- */
6
-
7
- export { ConfigSchema as ClientConfigSchema, type Config as ClientConfig } from '@open-wa/config';
8
-
9
- /**
10
- * Migrates a v4 configuration object to the v5 schema format.
11
- * Currently, most v4 options are compatible with v5.
12
- * This function serves as a placeholder for any future transformations.
13
- *
14
- * @deprecated This is a legacy compatibility function. Use @open-wa/config directly.
15
- */
16
- export function migrateV4Config(oldConfig: Record<string, unknown>): Record<string, unknown> {
17
- // Deep clone to avoid mutating original
18
- const config = JSON.parse(JSON.stringify(oldConfig));
19
-
20
- // Example migration: if 'authTimeout' was string in some legacy version (unlikely but example)
21
- if (typeof config.authTimeout === 'string') {
22
- config.authTimeout = parseInt(config.authTimeout, 10);
23
- }
24
-
25
- if (config.apiLifecycle === undefined) {
26
- config.apiLifecycle = 'hybrid';
27
- }
28
-
29
- return config;
30
- }
@@ -1,41 +0,0 @@
1
- import { chatIdCodec, contactIdCodec, groupIdCodec } from './codecs';
2
-
3
- describe('Zod Codecs', () => {
4
- describe('chatIdCodec', () => {
5
- it('should convert regular phone number to @c.us', () => {
6
- expect(chatIdCodec.decode('447123456789')).toBe('447123456789@c.us');
7
- });
8
-
9
- it('should convert 18-digit number to @g.us', () => {
10
- expect(chatIdCodec.decode('123456789012345678')).toBe('123456789012345678@g.us');
11
- });
12
-
13
- it('should convert 14-digit non-Indonesian to @lid', () => {
14
- expect(chatIdCodec.decode('12345678901234')).toBe('12345678901234@lid');
15
- });
16
-
17
- it('should convert 14-digit Indonesian to @c.us', () => {
18
- expect(chatIdCodec.decode('62812345678901')).toBe('62812345678901@c.us');
19
- });
20
-
21
- it('should pass through already formatted IDs', () => {
22
- expect(chatIdCodec.decode('447123456789@c.us')).toBe('447123456789@c.us');
23
- expect(chatIdCodec.decode('123456789012345678@g.us')).toBe('123456789012345678@g.us');
24
- expect(chatIdCodec.decode('12345678901234@lid')).toBe('12345678901234@lid');
25
- });
26
- });
27
-
28
- describe('contactIdCodec', () => {
29
- it('should always convert to @c.us', () => {
30
- expect(contactIdCodec.decode('447123456789')).toBe('447123456789@c.us');
31
- expect(contactIdCodec.decode('447123456789@c.us')).toBe('447123456789@c.us');
32
- });
33
- });
34
-
35
- describe('groupIdCodec', () => {
36
- it('should always convert to @g.us', () => {
37
- expect(groupIdCodec.decode('123456789012345678')).toBe('123456789012345678@g.us');
38
- expect(groupIdCodec.decode('123456789012345678@g.us')).toBe('123456789012345678@g.us');
39
- });
40
- });
41
- });