@teleporthq/teleport-plugin-next-workflows 0.43.74 → 0.43.75
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/__tests__/emit-custom-event-channel.test.ts +13 -0
- package/__tests__/payment-driver-stripe.test.ts +23 -0
- package/__tests__/payment-subscription-nodes.test.ts +8 -0
- package/dist/cjs/data-api-route-generator.d.ts +6 -8
- package/dist/cjs/data-api-route-generator.d.ts.map +1 -1
- package/dist/cjs/data-api-route-generator.js +6 -15
- package/dist/cjs/data-api-route-generator.js.map +1 -1
- package/dist/cjs/nodes/general/general-emit-custom-event.d.ts.map +1 -1
- package/dist/cjs/nodes/general/general-emit-custom-event.js +3 -1
- package/dist/cjs/nodes/general/general-emit-custom-event.js.map +1 -1
- package/dist/cjs/payments/drivers/stripe-driver-code.d.ts.map +1 -1
- package/dist/cjs/payments/drivers/stripe-driver-code.js +11 -0
- package/dist/cjs/payments/drivers/stripe-driver-code.js.map +1 -1
- package/dist/cjs/tsconfig.tsbuildinfo +1 -1
- package/dist/esm/data-api-route-generator.d.ts +6 -8
- package/dist/esm/data-api-route-generator.d.ts.map +1 -1
- package/dist/esm/data-api-route-generator.js +7 -16
- package/dist/esm/data-api-route-generator.js.map +1 -1
- package/dist/esm/nodes/general/general-emit-custom-event.d.ts.map +1 -1
- package/dist/esm/nodes/general/general-emit-custom-event.js +3 -1
- package/dist/esm/nodes/general/general-emit-custom-event.js.map +1 -1
- package/dist/esm/payments/drivers/stripe-driver-code.d.ts.map +1 -1
- package/dist/esm/payments/drivers/stripe-driver-code.js +11 -0
- package/dist/esm/payments/drivers/stripe-driver-code.js.map +1 -1
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -4
- package/src/data-api-route-generator.ts +8 -18
- package/src/nodes/general/general-emit-custom-event.ts +3 -1
- package/src/payments/drivers/stripe-driver-code.ts +11 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { generalEmitCustomEvent } from '../src/nodes/general/general-emit-custom-event'
|
|
2
|
+
|
|
3
|
+
describe('Emit Custom Event', () => {
|
|
4
|
+
/*
|
|
5
|
+
* The trigger side listens on `workflow:custom:<name>` (trigger-generator). The
|
|
6
|
+
* step used to dispatch the bare name, so "A Custom Event is Triggered" never
|
|
7
|
+
* started a workflow.
|
|
8
|
+
*/
|
|
9
|
+
it('dispatches on the channel the trigger listens to', () => {
|
|
10
|
+
const handler = generalEmitCustomEvent.generateHandler()
|
|
11
|
+
expect(handler).toContain("new CustomEvent('workflow:custom:' + eventName")
|
|
12
|
+
})
|
|
13
|
+
})
|
|
@@ -265,3 +265,26 @@ describe('Stripe driver — settling a checkout from Stripe', () => {
|
|
|
265
265
|
expect(calls).toEqual([])
|
|
266
266
|
})
|
|
267
267
|
})
|
|
268
|
+
|
|
269
|
+
describe('Stripe driver — checkout lifetime', () => {
|
|
270
|
+
it("opens every Checkout page for an hour, not Stripe's default day", async () => {
|
|
271
|
+
const { stripe, calls } = load()
|
|
272
|
+
const before = Math.floor(Date.now() / 1000)
|
|
273
|
+
await withEnv(KEY, async () => {
|
|
274
|
+
await stripe.createCheckout({ amount: 10, currency: 'usd', description: 'Order' })
|
|
275
|
+
await stripe.createSubscriptionCheckout({
|
|
276
|
+
amount: 10,
|
|
277
|
+
currency: 'usd',
|
|
278
|
+
recurringInterval: 'month',
|
|
279
|
+
description: 'Club',
|
|
280
|
+
})
|
|
281
|
+
})
|
|
282
|
+
const after = Math.floor(Date.now() / 1000)
|
|
283
|
+
const sessions = calls.filter((call: any) => call.method === 'checkout.sessions.create')
|
|
284
|
+
expect(sessions).toHaveLength(2)
|
|
285
|
+
for (const session of sessions as any[]) {
|
|
286
|
+
expect(session.params.expires_at).toBeGreaterThanOrEqual(before + 3600)
|
|
287
|
+
expect(session.params.expires_at).toBeLessThanOrEqual(after + 3600)
|
|
288
|
+
}
|
|
289
|
+
})
|
|
290
|
+
})
|
|
@@ -135,6 +135,7 @@ describe('payment-charge-user in subscription mode', () => {
|
|
|
135
135
|
paymentDrivers: loadPaymentDrivers({ stripe: FakeStripe }),
|
|
136
136
|
})
|
|
137
137
|
const metadata = { orderId: 'order-1', subscriptionId: 'sub-row-1' }
|
|
138
|
+
const before = Math.floor(Date.now() / 1000)
|
|
138
139
|
await withEnv({ STRIPE_SECRET_KEY: 'sk_test_1' }, async () => {
|
|
139
140
|
const result = await stripeHandler(
|
|
140
141
|
{
|
|
@@ -163,6 +164,7 @@ describe('payment-charge-user in subscription mode', () => {
|
|
|
163
164
|
__redirectUrl: 'https://checkout.stripe.com/c/cs_sub',
|
|
164
165
|
})
|
|
165
166
|
})
|
|
167
|
+
const after = Math.floor(Date.now() / 1000)
|
|
166
168
|
expect(calls).toEqual([
|
|
167
169
|
{
|
|
168
170
|
method: 'checkout.sessions.create',
|
|
@@ -170,6 +172,7 @@ describe('payment-charge-user in subscription mode', () => {
|
|
|
170
172
|
mode: 'subscription',
|
|
171
173
|
success_url: 'https://store.test/ok',
|
|
172
174
|
cancel_url: 'https://store.test/checkout',
|
|
175
|
+
expires_at: expect.any(Number),
|
|
173
176
|
line_items: [
|
|
174
177
|
{
|
|
175
178
|
price_data: {
|
|
@@ -186,6 +189,11 @@ describe('payment-charge-user in subscription mode', () => {
|
|
|
186
189
|
},
|
|
187
190
|
},
|
|
188
191
|
])
|
|
192
|
+
// A subscription checkout holds the order's stock too, so its page closes
|
|
193
|
+
// after the same 60 minutes as a one-off payment's.
|
|
194
|
+
const expiresAt = (calls[0].params as { expires_at: number }).expires_at
|
|
195
|
+
expect(expiresAt).toBeGreaterThanOrEqual(before + 3600)
|
|
196
|
+
expect(expiresAt).toBeLessThanOrEqual(after + 3600)
|
|
189
197
|
expect(resolveHandlerEntryName(source, 'payment-charge-user')).toBe('payment_charge_user')
|
|
190
198
|
})
|
|
191
199
|
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
* All interpolated identifiers (table names, column names, sort fields, filter
|
|
11
11
|
* fields) are validated to prevent SQL injection.
|
|
12
12
|
*/
|
|
13
|
+
import { ContentTables } from '@teleporthq/teleport-shared';
|
|
13
14
|
export declare const needsDataAPIRoute: (usedNodeTypes: Set<string>) => boolean;
|
|
14
15
|
export interface DataAPIRouteOptions {
|
|
15
16
|
authUsersTableName?: string;
|
|
@@ -34,14 +35,11 @@ export interface DataAPIRouteOptions {
|
|
|
34
35
|
export declare const BROWSER_READABLE_TABLES: ReadonlyArray<string>;
|
|
35
36
|
/**
|
|
36
37
|
* What a browser is served of the readable tables whose unpublished rows sit
|
|
37
|
-
* beside the public ones — the same
|
|
38
|
-
* (teleport-plugin-next-data-source `browser-row-policy.ts
|
|
39
|
-
*
|
|
40
|
-
*
|
|
38
|
+
* beside the public ones — the same map the per-table read routes apply
|
|
39
|
+
* (teleport-plugin-next-data-source `browser-row-policy.ts`): both read it from
|
|
40
|
+
* teleport-shared. A browser may not filter or sort by a hidden column: a
|
|
41
|
+
* filter is an oracle for a column it never returns.
|
|
41
42
|
*/
|
|
42
|
-
export declare const BROWSER_ROW_POLICIES: Readonly<Record<string,
|
|
43
|
-
predicate: string;
|
|
44
|
-
hiddenColumns: ReadonlyArray<string>;
|
|
45
|
-
}>>;
|
|
43
|
+
export declare const BROWSER_ROW_POLICIES: Readonly<Record<string, ContentTables.VisitorRowPolicy>>;
|
|
46
44
|
export declare const generateDataAPIRoute: (options?: DataAPIRouteOptions) => string;
|
|
47
45
|
//# sourceMappingURL=data-api-route-generator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-api-route-generator.d.ts","sourceRoot":"","sources":["../../src/data-api-route-generator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;
|
|
1
|
+
{"version":3,"file":"data-api-route-generator.d.ts","sourceRoot":"","sources":["../../src/data-api-route-generator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH,OAAO,EAAE,aAAa,EAAe,MAAM,6BAA6B,CAAA;AAexE,eAAO,MAAM,iBAAiB,kBAAmB,IAAI,MAAM,CAAC,KAAG,OAO9D,CAAA;AAED,MAAM,WAAW,mBAAmB;IAIlC,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAQ3B,qBAAqB,CAAC,EAAE,OAAO,CAAA;IAI/B,iBAAiB,CAAC,EAAE,MAAM,CAAA;CAC3B;AAED;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,uBAAuB,EAAE,aAAa,CAAC,MAAM,CASzD,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,gBAAgB,CAAC,CACtD,CAAA;AAEpC,eAAO,MAAM,oBAAoB,aAAa,mBAAmB,KAAQ,MAiqCxE,CAAA"}
|
|
@@ -60,25 +60,16 @@ exports.BROWSER_READABLE_TABLES = [
|
|
|
60
60
|
'teleport_shipping_rates',
|
|
61
61
|
'teleport_tax_rates',
|
|
62
62
|
'teleport_store_locations',
|
|
63
|
-
|
|
63
|
+
...teleport_shared_1.ContentTables.CONTENT_POSTS_TABLES,
|
|
64
64
|
];
|
|
65
65
|
/**
|
|
66
66
|
* What a browser is served of the readable tables whose unpublished rows sit
|
|
67
|
-
* beside the public ones — the same
|
|
68
|
-
* (teleport-plugin-next-data-source `browser-row-policy.ts
|
|
69
|
-
*
|
|
70
|
-
*
|
|
67
|
+
* beside the public ones — the same map the per-table read routes apply
|
|
68
|
+
* (teleport-plugin-next-data-source `browser-row-policy.ts`): both read it from
|
|
69
|
+
* teleport-shared. A browser may not filter or sort by a hidden column: a
|
|
70
|
+
* filter is an oracle for a column it never returns.
|
|
71
71
|
*/
|
|
72
|
-
exports.BROWSER_ROW_POLICIES =
|
|
73
|
-
teleport_blog_posts: {
|
|
74
|
-
predicate: "status = 'published'",
|
|
75
|
-
hiddenColumns: ['author_email', 'authorEmail'],
|
|
76
|
-
},
|
|
77
|
-
teleport_products: {
|
|
78
|
-
predicate: "LOWER(TRIM(status)) = 'active'",
|
|
79
|
-
hiddenColumns: [],
|
|
80
|
-
},
|
|
81
|
-
};
|
|
72
|
+
exports.BROWSER_ROW_POLICIES = teleport_shared_1.ContentTables.VISITOR_ROW_POLICIES;
|
|
82
73
|
const generateDataAPIRoute = (options = {}) => {
|
|
83
74
|
const validatorCode = (0, sql_validator_1.generateSqlValidatorCode)();
|
|
84
75
|
const authUsersTable = options.authUsersTableName || null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-api-route-generator.js","sourceRoot":"","sources":["../../src/data-api-route-generator.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG;;;AAEH,mDAA0D;AAC1D,uEAAoF;AACpF,
|
|
1
|
+
{"version":3,"file":"data-api-route-generator.js","sourceRoot":"","sources":["../../src/data-api-route-generator.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG;;;AAEH,mDAA0D;AAC1D,uEAAoF;AACpF,iEAAwE;AAExE,MAAM,eAAe,GAAG,IAAI,GAAG,CAAC;IAC9B,aAAa;IACb,kBAAkB;IAClB,kBAAkB;IAClB,kBAAkB;IAClB,YAAY;IACZ,gBAAgB;IAChB,uEAAuE;IACvE,0EAA0E;IAC1E,sCAAsC;IACtC,yBAAyB;CAC1B,CAAC,CAAA;AAEK,MAAM,iBAAiB,GAAG,CAAC,aAA0B,EAAW,EAAE;IACvE,KAAK,MAAM,EAAE,IAAI,aAAa,EAAE;QAC9B,IAAI,eAAe,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE;YAC3B,OAAO,IAAI,CAAA;SACZ;KACF;IACD,OAAO,KAAK,CAAA;AACd,CAAC,CAAA;AAPY,QAAA,iBAAiB,qBAO7B;AAqBD;;;;;;;;;;;;;;GAcG;AACU,QAAA,uBAAuB,GAA0B;IAC5D,mBAAmB;IACnB,2BAA2B;IAC3B,oBAAoB;IACpB,yBAAyB;IACzB,yBAAyB;IACzB,oBAAoB;IACpB,0BAA0B;IAC1B,GAAG,+BAAa,CAAC,oBAAoB;CAC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oBAAoB,wBAiqChC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"general-emit-custom-event.d.ts","sourceRoot":"","sources":["../../../../src/nodes/general/general-emit-custom-event.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAmB,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"general-emit-custom-event.d.ts","sourceRoot":"","sources":["../../../../src/nodes/general/general-emit-custom-event.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAmB,MAAM,UAAU,CAAA;AAyBhE,eAAO,MAAM,sBAAsB,EAAE,oBAMpC,CAAA"}
|
|
@@ -11,7 +11,9 @@ async function general_emit_custom_event(config, context) {
|
|
|
11
11
|
const GLOBAL_SCOPE = 'glo' + 'bal';
|
|
12
12
|
const scope = config.scope || GLOBAL_SCOPE;
|
|
13
13
|
try {
|
|
14
|
-
|
|
14
|
+
// The "A Custom Event is Triggered" workflow listens on this channel (see
|
|
15
|
+
// trigger-generator); a bare name started nothing.
|
|
16
|
+
const event = new CustomEvent('workflow:custom:' + eventName, {
|
|
15
17
|
detail: eventData,
|
|
16
18
|
bubbles: scope === GLOBAL_SCOPE,
|
|
17
19
|
cancelable: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"general-emit-custom-event.js","sourceRoot":"","sources":["../../../../src/nodes/general/general-emit-custom-event.ts"],"names":[],"mappings":";;;AAAA,oCAAgE;AAEhE,KAAK,UAAU,yBAAyB,CAAC,MAAW,EAAE,OAAgC;IACpF,MAAM,SAAS,GAAG,MAAM,CAAC,SAAS,CAAA;IAClC,MAAM,SAAS,GAAG,MAAM,CAAC,SAAS,IAAI,EAAE,CAAA;IACxC,oEAAoE;IACpE,yEAAyE;IACzE,4EAA4E;IAC5E,MAAM,YAAY,GAAG,KAAK,GAAG,KAAK,CAAA;IAClC,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,IAAI,YAAY,CAAA;IAE1C,IAAI;QACF,MAAM,KAAK,GAAG,IAAI,WAAW,CAAC,SAAS,EAAE;
|
|
1
|
+
{"version":3,"file":"general-emit-custom-event.js","sourceRoot":"","sources":["../../../../src/nodes/general/general-emit-custom-event.ts"],"names":[],"mappings":";;;AAAA,oCAAgE;AAEhE,KAAK,UAAU,yBAAyB,CAAC,MAAW,EAAE,OAAgC;IACpF,MAAM,SAAS,GAAG,MAAM,CAAC,SAAS,CAAA;IAClC,MAAM,SAAS,GAAG,MAAM,CAAC,SAAS,IAAI,EAAE,CAAA;IACxC,oEAAoE;IACpE,yEAAyE;IACzE,4EAA4E;IAC5E,MAAM,YAAY,GAAG,KAAK,GAAG,KAAK,CAAA;IAClC,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,IAAI,YAAY,CAAA;IAE1C,IAAI;QACF,0EAA0E;QAC1E,mDAAmD;QACnD,MAAM,KAAK,GAAG,IAAI,WAAW,CAAC,kBAAkB,GAAG,SAAS,EAAE;YAC5D,MAAM,EAAE,SAAS;YACjB,OAAO,EAAE,KAAK,KAAK,YAAY;YAC/B,UAAU,EAAE,IAAI;SACjB,CAAC,CAAA;QACF,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,CAAA;QAC3B,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAA;KACzB;IAAC,OAAO,GAAY,EAAE;QACrB,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAG,GAAa,CAAC,OAAO,EAAE,CAAA;KACzD;AACH,CAAC;AACY,QAAA,sBAAsB,GAAyB;IAC1D,QAAQ,EAAE,2BAA2B;IACrC,YAAY,EAAE,QAAQ;IACtB,eAAe;QACb,OAAO,IAAA,uBAAe,EAAC,yBAAyB,CAAC,CAAA;IACnD,CAAC;CACF,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stripe-driver-code.d.ts","sourceRoot":"","sources":["../../../../src/payments/drivers/stripe-driver-code.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,eAAO,MAAM,wBAAwB,QAAO,
|
|
1
|
+
{"version":3,"file":"stripe-driver-code.d.ts","sourceRoot":"","sources":["../../../../src/payments/drivers/stripe-driver-code.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,eAAO,MAAM,wBAAwB,QAAO,MAqwB3C,CAAA"}
|
|
@@ -19,6 +19,15 @@ module.exports = function createStripeDriver(core) {
|
|
|
19
19
|
// An older store's test key, read after the names the editor saves.
|
|
20
20
|
var LEGACY_SECRET_KEY_NAMES = ['STRIPE_TEST_KEY'];
|
|
21
21
|
var MISSING_KEY = 'STRIPE_SECRET_KEY is not configured';
|
|
22
|
+
// How long a Checkout page takes money. Stripe's default is a day, which is
|
|
23
|
+
// how long an abandoned checkout would hold its stock on a store without
|
|
24
|
+
// the scheduled release; the store's own hold is 60 minutes, and Stripe
|
|
25
|
+
// takes no less than 30.
|
|
26
|
+
var CHECKOUT_LIFETIME_MINUTES = 60;
|
|
27
|
+
|
|
28
|
+
function checkoutExpiresAt() {
|
|
29
|
+
return Math.floor(Date.now() / 1000) + CHECKOUT_LIFETIME_MINUTES * 60;
|
|
30
|
+
}
|
|
22
31
|
var INTERVALS = ['day', 'week', 'month', 'year'];
|
|
23
32
|
// Checkout tolerates a signature this old, as Stripe's own libraries do.
|
|
24
33
|
var SIGNATURE_TOLERANCE_SECONDS = 300;
|
|
@@ -65,6 +74,7 @@ module.exports = function createStripeDriver(core) {
|
|
|
65
74
|
mode: 'payment',
|
|
66
75
|
success_url: input.successUrl || undefined,
|
|
67
76
|
cancel_url: input.cancelUrl || undefined,
|
|
77
|
+
expires_at: checkoutExpiresAt(),
|
|
68
78
|
};
|
|
69
79
|
var lineItems = input.lineItems;
|
|
70
80
|
if (lineItems && Array.isArray(lineItems) && lineItems.length > 0) {
|
|
@@ -154,6 +164,7 @@ module.exports = function createStripeDriver(core) {
|
|
|
154
164
|
mode: 'subscription',
|
|
155
165
|
success_url: input.successUrl || undefined,
|
|
156
166
|
cancel_url: input.cancelUrl || undefined,
|
|
167
|
+
expires_at: checkoutExpiresAt(),
|
|
157
168
|
line_items: [
|
|
158
169
|
{
|
|
159
170
|
price_data: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stripe-driver-code.js","sourceRoot":"","sources":["../../../../src/payments/drivers/stripe-driver-code.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;GASG;AACI,MAAM,wBAAwB,GAAG,GAAW,EAAE,CAAC
|
|
1
|
+
{"version":3,"file":"stripe-driver-code.js","sourceRoot":"","sources":["../../../../src/payments/drivers/stripe-driver-code.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;GASG;AACI,MAAM,wBAAwB,GAAG,GAAW,EAAE,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqwBrD,CAAA;AArwBY,QAAA,wBAAwB,4BAqwBpC"}
|