@uniforge/testing 0.1.0-alpha.2
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/auth/index.d.cts +177 -0
- package/dist/auth/index.d.ts +177 -0
- package/dist/auth/index.js +459 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/auth/index.mjs +418 -0
- package/dist/auth/index.mjs.map +1 -0
- package/dist/billing/index.d.cts +27 -0
- package/dist/billing/index.d.ts +27 -0
- package/dist/billing/index.js +208 -0
- package/dist/billing/index.js.map +1 -0
- package/dist/billing/index.mjs +178 -0
- package/dist/billing/index.mjs.map +1 -0
- package/dist/database/index.d.cts +399 -0
- package/dist/database/index.d.ts +399 -0
- package/dist/database/index.js +19054 -0
- package/dist/database/index.js.map +1 -0
- package/dist/database/index.mjs +19046 -0
- package/dist/database/index.mjs.map +1 -0
- package/dist/graphql/index.d.cts +23 -0
- package/dist/graphql/index.d.ts +23 -0
- package/dist/graphql/index.js +18511 -0
- package/dist/graphql/index.js.map +1 -0
- package/dist/graphql/index.mjs +18505 -0
- package/dist/graphql/index.mjs.map +1 -0
- package/dist/index.d.cts +10 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +31 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +6 -0
- package/dist/index.mjs.map +1 -0
- package/dist/multi-store/index.d.cts +66 -0
- package/dist/multi-store/index.d.ts +66 -0
- package/dist/multi-store/index.js +319 -0
- package/dist/multi-store/index.js.map +1 -0
- package/dist/multi-store/index.mjs +287 -0
- package/dist/multi-store/index.mjs.map +1 -0
- package/dist/multi-tenant/index.d.cts +15 -0
- package/dist/multi-tenant/index.d.ts +15 -0
- package/dist/multi-tenant/index.js +87 -0
- package/dist/multi-tenant/index.js.map +1 -0
- package/dist/multi-tenant/index.mjs +57 -0
- package/dist/multi-tenant/index.mjs.map +1 -0
- package/dist/performance/index.d.cts +60 -0
- package/dist/performance/index.d.ts +60 -0
- package/dist/performance/index.js +280 -0
- package/dist/performance/index.js.map +1 -0
- package/dist/performance/index.mjs +246 -0
- package/dist/performance/index.mjs.map +1 -0
- package/dist/platform/index.d.cts +71 -0
- package/dist/platform/index.d.ts +71 -0
- package/dist/platform/index.js +435 -0
- package/dist/platform/index.js.map +1 -0
- package/dist/platform/index.mjs +396 -0
- package/dist/platform/index.mjs.map +1 -0
- package/dist/rbac/index.d.cts +21 -0
- package/dist/rbac/index.d.ts +21 -0
- package/dist/rbac/index.js +178 -0
- package/dist/rbac/index.js.map +1 -0
- package/dist/rbac/index.mjs +150 -0
- package/dist/rbac/index.mjs.map +1 -0
- package/dist/security/index.d.cts +73 -0
- package/dist/security/index.d.ts +73 -0
- package/dist/security/index.js +246 -0
- package/dist/security/index.js.map +1 -0
- package/dist/security/index.mjs +211 -0
- package/dist/security/index.mjs.map +1 -0
- package/dist/shopify-api/index.d.cts +139 -0
- package/dist/shopify-api/index.d.ts +139 -0
- package/dist/shopify-api/index.js +469 -0
- package/dist/shopify-api/index.js.map +1 -0
- package/dist/shopify-api/index.mjs +439 -0
- package/dist/shopify-api/index.mjs.map +1 -0
- package/dist/shopify-compliance/index.d.cts +85 -0
- package/dist/shopify-compliance/index.d.ts +85 -0
- package/dist/shopify-compliance/index.js +287 -0
- package/dist/shopify-compliance/index.js.map +1 -0
- package/dist/shopify-compliance/index.mjs +259 -0
- package/dist/shopify-compliance/index.mjs.map +1 -0
- package/dist/webhooks/index.d.cts +127 -0
- package/dist/webhooks/index.d.ts +127 -0
- package/dist/webhooks/index.js +18934 -0
- package/dist/webhooks/index.js.map +1 -0
- package/dist/webhooks/index.mjs +18916 -0
- package/dist/webhooks/index.mjs.map +1 -0
- package/package.json +112 -0
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import * as vitest from 'vitest';
|
|
2
|
+
import { WebhookPayload, WebhookJob, WebhookHandlerResult, WebhookHandler } from '@uniforge/platform-core/webhooks';
|
|
3
|
+
|
|
4
|
+
declare function createMockWebhookPayload(overrides?: Partial<WebhookPayload>): WebhookPayload;
|
|
5
|
+
declare function createMockWebhookJob(overrides?: Partial<WebhookJob>): WebhookJob;
|
|
6
|
+
declare function createMockWebhookHandler(result?: Partial<WebhookHandlerResult>): WebhookHandler;
|
|
7
|
+
declare function createMockWebhookQueue(): {
|
|
8
|
+
enqueue: vitest.Mock<(...args: any[]) => any>;
|
|
9
|
+
getJob: vitest.Mock<(...args: any[]) => any>;
|
|
10
|
+
acknowledgeJob: vitest.Mock<(...args: any[]) => any>;
|
|
11
|
+
requeueJob: vitest.Mock<(...args: any[]) => any>;
|
|
12
|
+
dequeueNext: vitest.Mock<(...args: any[]) => any>;
|
|
13
|
+
getDeadLetterJobs: vitest.Mock<(...args: any[]) => any>;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Webhook delivery simulator for testing.
|
|
18
|
+
*
|
|
19
|
+
* Simulates Shopify webhook delivery via HTTP with proper HMAC signatures,
|
|
20
|
+
* headers, retry logic, and delivery history tracking.
|
|
21
|
+
*/
|
|
22
|
+
interface WebhookSimulatorConfig {
|
|
23
|
+
targetUrl: string;
|
|
24
|
+
secret: string;
|
|
25
|
+
apiVersion?: string;
|
|
26
|
+
defaultShopDomain?: string;
|
|
27
|
+
}
|
|
28
|
+
interface WebhookDeliveryInput {
|
|
29
|
+
topic: string;
|
|
30
|
+
payload: unknown;
|
|
31
|
+
shopDomain?: string;
|
|
32
|
+
}
|
|
33
|
+
interface WebhookDeliveryResult {
|
|
34
|
+
topic: string;
|
|
35
|
+
shopDomain: string;
|
|
36
|
+
statusCode: number;
|
|
37
|
+
success: boolean;
|
|
38
|
+
responseBody: string;
|
|
39
|
+
deliveredAt: Date;
|
|
40
|
+
attempt: number;
|
|
41
|
+
hmac: string;
|
|
42
|
+
webhookId: string;
|
|
43
|
+
}
|
|
44
|
+
interface RetryOptions {
|
|
45
|
+
maxAttempts?: number;
|
|
46
|
+
delayMs?: number;
|
|
47
|
+
backoffMultiplier?: number;
|
|
48
|
+
}
|
|
49
|
+
declare class WebhookSimulator {
|
|
50
|
+
private readonly targetUrl;
|
|
51
|
+
private readonly secret;
|
|
52
|
+
private readonly apiVersion;
|
|
53
|
+
private readonly defaultShopDomain;
|
|
54
|
+
private readonly history;
|
|
55
|
+
constructor(config: WebhookSimulatorConfig);
|
|
56
|
+
deliver(topic: string, payload: unknown, shopDomain?: string): Promise<WebhookDeliveryResult>;
|
|
57
|
+
deliverBatch(webhooks: WebhookDeliveryInput[]): Promise<WebhookDeliveryResult[]>;
|
|
58
|
+
deliverWithRetries(topic: string, payload: unknown, options?: RetryOptions): Promise<WebhookDeliveryResult[]>;
|
|
59
|
+
getDeliveryHistory(): WebhookDeliveryResult[];
|
|
60
|
+
clearHistory(): void;
|
|
61
|
+
private sendRequest;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Webhook payload generators for testing.
|
|
66
|
+
*
|
|
67
|
+
* Generates realistic Shopify webhook payloads with sensible defaults.
|
|
68
|
+
* All generators accept optional overrides to customize the output.
|
|
69
|
+
*/
|
|
70
|
+
interface OrderPayloadData {
|
|
71
|
+
id?: number;
|
|
72
|
+
orderNumber?: number;
|
|
73
|
+
email?: string;
|
|
74
|
+
totalPrice?: string;
|
|
75
|
+
currency?: string;
|
|
76
|
+
financialStatus?: string;
|
|
77
|
+
fulfillmentStatus?: string | null;
|
|
78
|
+
lineItems?: Array<{
|
|
79
|
+
id?: number;
|
|
80
|
+
title?: string;
|
|
81
|
+
quantity?: number;
|
|
82
|
+
price?: string;
|
|
83
|
+
sku?: string;
|
|
84
|
+
}>;
|
|
85
|
+
}
|
|
86
|
+
interface ProductPayloadData {
|
|
87
|
+
id?: number;
|
|
88
|
+
title?: string;
|
|
89
|
+
vendor?: string;
|
|
90
|
+
productType?: string;
|
|
91
|
+
status?: string;
|
|
92
|
+
handle?: string;
|
|
93
|
+
variants?: Array<{
|
|
94
|
+
id?: number;
|
|
95
|
+
title?: string;
|
|
96
|
+
price?: string;
|
|
97
|
+
sku?: string;
|
|
98
|
+
inventoryQuantity?: number;
|
|
99
|
+
}>;
|
|
100
|
+
}
|
|
101
|
+
interface CustomerPayloadData {
|
|
102
|
+
id?: number;
|
|
103
|
+
email?: string;
|
|
104
|
+
firstName?: string;
|
|
105
|
+
lastName?: string;
|
|
106
|
+
phone?: string;
|
|
107
|
+
ordersCount?: number;
|
|
108
|
+
totalSpent?: string;
|
|
109
|
+
}
|
|
110
|
+
interface SubscriptionPayloadData {
|
|
111
|
+
id?: number;
|
|
112
|
+
adminGraphqlApiId?: string;
|
|
113
|
+
name?: string;
|
|
114
|
+
status?: string;
|
|
115
|
+
}
|
|
116
|
+
declare function generateAppUninstalledPayload(shopDomain?: string): Record<string, unknown>;
|
|
117
|
+
declare function generateOrderCreatedPayload(overrides?: OrderPayloadData): Record<string, unknown>;
|
|
118
|
+
declare function generateOrderPaidPayload(overrides?: OrderPayloadData): Record<string, unknown>;
|
|
119
|
+
declare function generateProductCreatedPayload(overrides?: ProductPayloadData): Record<string, unknown>;
|
|
120
|
+
declare function generateProductUpdatedPayload(overrides?: ProductPayloadData): Record<string, unknown>;
|
|
121
|
+
declare function generateProductDeletedPayload(productId?: number): Record<string, unknown>;
|
|
122
|
+
declare function generateCustomerCreatedPayload(overrides?: CustomerPayloadData): Record<string, unknown>;
|
|
123
|
+
declare function generateCustomerUpdatedPayload(overrides?: CustomerPayloadData): Record<string, unknown>;
|
|
124
|
+
declare function generateSubscriptionUpdatePayload(overrides?: SubscriptionPayloadData): Record<string, unknown>;
|
|
125
|
+
declare function generatePayload(_topic: string, data?: Record<string, unknown>): Record<string, unknown>;
|
|
126
|
+
|
|
127
|
+
export { type CustomerPayloadData, type OrderPayloadData, type ProductPayloadData, type RetryOptions, type SubscriptionPayloadData, type WebhookDeliveryInput, type WebhookDeliveryResult, WebhookSimulator, type WebhookSimulatorConfig, createMockWebhookHandler, createMockWebhookJob, createMockWebhookPayload, createMockWebhookQueue, generateAppUninstalledPayload, generateCustomerCreatedPayload, generateCustomerUpdatedPayload, generateOrderCreatedPayload, generateOrderPaidPayload, generatePayload, generateProductCreatedPayload, generateProductDeletedPayload, generateProductUpdatedPayload, generateSubscriptionUpdatePayload };
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import * as vitest from 'vitest';
|
|
2
|
+
import { WebhookPayload, WebhookJob, WebhookHandlerResult, WebhookHandler } from '@uniforge/platform-core/webhooks';
|
|
3
|
+
|
|
4
|
+
declare function createMockWebhookPayload(overrides?: Partial<WebhookPayload>): WebhookPayload;
|
|
5
|
+
declare function createMockWebhookJob(overrides?: Partial<WebhookJob>): WebhookJob;
|
|
6
|
+
declare function createMockWebhookHandler(result?: Partial<WebhookHandlerResult>): WebhookHandler;
|
|
7
|
+
declare function createMockWebhookQueue(): {
|
|
8
|
+
enqueue: vitest.Mock<(...args: any[]) => any>;
|
|
9
|
+
getJob: vitest.Mock<(...args: any[]) => any>;
|
|
10
|
+
acknowledgeJob: vitest.Mock<(...args: any[]) => any>;
|
|
11
|
+
requeueJob: vitest.Mock<(...args: any[]) => any>;
|
|
12
|
+
dequeueNext: vitest.Mock<(...args: any[]) => any>;
|
|
13
|
+
getDeadLetterJobs: vitest.Mock<(...args: any[]) => any>;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Webhook delivery simulator for testing.
|
|
18
|
+
*
|
|
19
|
+
* Simulates Shopify webhook delivery via HTTP with proper HMAC signatures,
|
|
20
|
+
* headers, retry logic, and delivery history tracking.
|
|
21
|
+
*/
|
|
22
|
+
interface WebhookSimulatorConfig {
|
|
23
|
+
targetUrl: string;
|
|
24
|
+
secret: string;
|
|
25
|
+
apiVersion?: string;
|
|
26
|
+
defaultShopDomain?: string;
|
|
27
|
+
}
|
|
28
|
+
interface WebhookDeliveryInput {
|
|
29
|
+
topic: string;
|
|
30
|
+
payload: unknown;
|
|
31
|
+
shopDomain?: string;
|
|
32
|
+
}
|
|
33
|
+
interface WebhookDeliveryResult {
|
|
34
|
+
topic: string;
|
|
35
|
+
shopDomain: string;
|
|
36
|
+
statusCode: number;
|
|
37
|
+
success: boolean;
|
|
38
|
+
responseBody: string;
|
|
39
|
+
deliveredAt: Date;
|
|
40
|
+
attempt: number;
|
|
41
|
+
hmac: string;
|
|
42
|
+
webhookId: string;
|
|
43
|
+
}
|
|
44
|
+
interface RetryOptions {
|
|
45
|
+
maxAttempts?: number;
|
|
46
|
+
delayMs?: number;
|
|
47
|
+
backoffMultiplier?: number;
|
|
48
|
+
}
|
|
49
|
+
declare class WebhookSimulator {
|
|
50
|
+
private readonly targetUrl;
|
|
51
|
+
private readonly secret;
|
|
52
|
+
private readonly apiVersion;
|
|
53
|
+
private readonly defaultShopDomain;
|
|
54
|
+
private readonly history;
|
|
55
|
+
constructor(config: WebhookSimulatorConfig);
|
|
56
|
+
deliver(topic: string, payload: unknown, shopDomain?: string): Promise<WebhookDeliveryResult>;
|
|
57
|
+
deliverBatch(webhooks: WebhookDeliveryInput[]): Promise<WebhookDeliveryResult[]>;
|
|
58
|
+
deliverWithRetries(topic: string, payload: unknown, options?: RetryOptions): Promise<WebhookDeliveryResult[]>;
|
|
59
|
+
getDeliveryHistory(): WebhookDeliveryResult[];
|
|
60
|
+
clearHistory(): void;
|
|
61
|
+
private sendRequest;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Webhook payload generators for testing.
|
|
66
|
+
*
|
|
67
|
+
* Generates realistic Shopify webhook payloads with sensible defaults.
|
|
68
|
+
* All generators accept optional overrides to customize the output.
|
|
69
|
+
*/
|
|
70
|
+
interface OrderPayloadData {
|
|
71
|
+
id?: number;
|
|
72
|
+
orderNumber?: number;
|
|
73
|
+
email?: string;
|
|
74
|
+
totalPrice?: string;
|
|
75
|
+
currency?: string;
|
|
76
|
+
financialStatus?: string;
|
|
77
|
+
fulfillmentStatus?: string | null;
|
|
78
|
+
lineItems?: Array<{
|
|
79
|
+
id?: number;
|
|
80
|
+
title?: string;
|
|
81
|
+
quantity?: number;
|
|
82
|
+
price?: string;
|
|
83
|
+
sku?: string;
|
|
84
|
+
}>;
|
|
85
|
+
}
|
|
86
|
+
interface ProductPayloadData {
|
|
87
|
+
id?: number;
|
|
88
|
+
title?: string;
|
|
89
|
+
vendor?: string;
|
|
90
|
+
productType?: string;
|
|
91
|
+
status?: string;
|
|
92
|
+
handle?: string;
|
|
93
|
+
variants?: Array<{
|
|
94
|
+
id?: number;
|
|
95
|
+
title?: string;
|
|
96
|
+
price?: string;
|
|
97
|
+
sku?: string;
|
|
98
|
+
inventoryQuantity?: number;
|
|
99
|
+
}>;
|
|
100
|
+
}
|
|
101
|
+
interface CustomerPayloadData {
|
|
102
|
+
id?: number;
|
|
103
|
+
email?: string;
|
|
104
|
+
firstName?: string;
|
|
105
|
+
lastName?: string;
|
|
106
|
+
phone?: string;
|
|
107
|
+
ordersCount?: number;
|
|
108
|
+
totalSpent?: string;
|
|
109
|
+
}
|
|
110
|
+
interface SubscriptionPayloadData {
|
|
111
|
+
id?: number;
|
|
112
|
+
adminGraphqlApiId?: string;
|
|
113
|
+
name?: string;
|
|
114
|
+
status?: string;
|
|
115
|
+
}
|
|
116
|
+
declare function generateAppUninstalledPayload(shopDomain?: string): Record<string, unknown>;
|
|
117
|
+
declare function generateOrderCreatedPayload(overrides?: OrderPayloadData): Record<string, unknown>;
|
|
118
|
+
declare function generateOrderPaidPayload(overrides?: OrderPayloadData): Record<string, unknown>;
|
|
119
|
+
declare function generateProductCreatedPayload(overrides?: ProductPayloadData): Record<string, unknown>;
|
|
120
|
+
declare function generateProductUpdatedPayload(overrides?: ProductPayloadData): Record<string, unknown>;
|
|
121
|
+
declare function generateProductDeletedPayload(productId?: number): Record<string, unknown>;
|
|
122
|
+
declare function generateCustomerCreatedPayload(overrides?: CustomerPayloadData): Record<string, unknown>;
|
|
123
|
+
declare function generateCustomerUpdatedPayload(overrides?: CustomerPayloadData): Record<string, unknown>;
|
|
124
|
+
declare function generateSubscriptionUpdatePayload(overrides?: SubscriptionPayloadData): Record<string, unknown>;
|
|
125
|
+
declare function generatePayload(_topic: string, data?: Record<string, unknown>): Record<string, unknown>;
|
|
126
|
+
|
|
127
|
+
export { type CustomerPayloadData, type OrderPayloadData, type ProductPayloadData, type RetryOptions, type SubscriptionPayloadData, type WebhookDeliveryInput, type WebhookDeliveryResult, WebhookSimulator, type WebhookSimulatorConfig, createMockWebhookHandler, createMockWebhookJob, createMockWebhookPayload, createMockWebhookQueue, generateAppUninstalledPayload, generateCustomerCreatedPayload, generateCustomerUpdatedPayload, generateOrderCreatedPayload, generateOrderPaidPayload, generatePayload, generateProductCreatedPayload, generateProductDeletedPayload, generateProductUpdatedPayload, generateSubscriptionUpdatePayload };
|