@drawbridge/drawbridge-utils 0.0.175 → 0.0.177
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/admin-B9ZaLvan.d.cts +697 -0
- package/dist/admin-C3HtEM6h.d.ts +697 -0
- package/dist/billing-Bc4yo9XG.d.cts +175 -0
- package/dist/billing-mNsKflmQ.d.ts +175 -0
- package/dist/billing.d.cts +1 -1
- package/dist/billing.d.ts +1 -1
- package/dist/connections/index.cjs +5928 -1920
- package/dist/connections/index.d.cts +20 -9163
- package/dist/connections/index.d.ts +20 -9163
- package/dist/connections/index.js +5917 -1921
- package/dist/connections/oauth.cjs +4 -4
- package/dist/connections/oauth.d.cts +10 -8
- package/dist/connections/oauth.d.ts +10 -8
- package/dist/connections/oauth.js +4 -4
- package/dist/features.cjs +10260 -42
- package/dist/features.d.cts +55 -42
- package/dist/features.d.ts +55 -42
- package/dist/features.js +10254 -42
- package/dist/http.cjs +10 -1
- package/dist/http.d.cts +10 -1
- package/dist/http.d.ts +10 -1
- package/dist/http.js +10 -1
- package/dist/index-B546oDNo.d.ts +13809 -0
- package/dist/index-C59xHago.d.cts +13809 -0
- package/dist/oauth/index.d.cts +1 -1
- package/dist/oauth/index.d.ts +1 -1
- package/dist/oauth-BJDh0sdM.d.cts +527 -0
- package/dist/oauth-DveZMLHx.d.ts +527 -0
- package/dist/partner-BOZltuh2.d.ts +94 -0
- package/dist/partner-ed2OfW1J.d.cts +94 -0
- package/dist/plans.cjs +10256 -51
- package/dist/plans.d.cts +37 -10
- package/dist/plans.d.ts +37 -10
- package/dist/plans.js +10262 -51
- package/dist/pricing.cjs +10401 -209
- package/dist/pricing.d.cts +34 -17
- package/dist/pricing.d.ts +34 -17
- package/dist/pricing.js +10407 -209
- package/dist/providers.cjs +5433 -1755
- package/dist/providers.d.cts +13 -15
- package/dist/providers.d.ts +13 -15
- package/dist/providers.js +5436 -1752
- package/dist/sendgrid.cjs +10 -1
- package/dist/sendgrid.js +10 -1
- package/dist/shopify/admin.cjs +562 -0
- package/dist/shopify/admin.d.cts +3 -0
- package/dist/shopify/admin.d.ts +3 -0
- package/dist/shopify/admin.js +528 -0
- package/dist/shopify/billing.cjs +166 -0
- package/dist/shopify/billing.d.cts +3 -0
- package/dist/shopify/billing.d.ts +3 -0
- package/dist/shopify/billing.js +140 -0
- package/dist/shopify/constants.cjs +63 -0
- package/dist/shopify/constants.d.cts +58 -0
- package/dist/shopify/constants.d.ts +58 -0
- package/dist/shopify/constants.js +32 -0
- package/dist/shopify/oauth.cjs +509 -0
- package/dist/shopify/oauth.d.cts +7 -0
- package/dist/shopify/oauth.d.ts +7 -0
- package/dist/shopify/oauth.js +466 -0
- package/dist/shopify/partner.cjs +156 -0
- package/dist/shopify/partner.d.cts +3 -0
- package/dist/shopify/partner.d.ts +3 -0
- package/dist/shopify/partner.js +130 -0
- package/dist/shopify/storefront.cjs +611 -0
- package/dist/shopify/storefront.d.cts +3 -0
- package/dist/shopify/storefront.d.ts +3 -0
- package/dist/shopify/storefront.js +576 -0
- package/dist/storefront-C8FKOGeD.d.cts +659 -0
- package/dist/storefront-DJFGLqPl.d.ts +659 -0
- package/dist/twilio.cjs +10 -1
- package/dist/twilio.js +10 -1
- package/package.json +98 -68
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { request } from './http.cjs';
|
|
2
|
+
import { PARTNER_API_VERSION } from './shopify/constants.cjs';
|
|
3
|
+
|
|
4
|
+
// The Partner API is the ONE place meter billing is observable. The Admin API
|
|
5
|
+
// never materializes managed-pricing meters as subscription line items
|
|
6
|
+
// (measured 2026-09-04, every version), and the App Events API answers 202
|
|
7
|
+
// whether or not anything billed — but a usage charge that ACCRUED appears
|
|
8
|
+
// here as a CHARGE_USAGE event, with the charge id, the amount, and the
|
|
9
|
+
// planHandle it classified under. Authenticated with a Partner API client
|
|
10
|
+
// token (Partner Dashboard → Settings → Partner API clients, Manage-apps
|
|
11
|
+
// permission), scoped to a partner organization.
|
|
12
|
+
|
|
13
|
+
const PARTNER_API = 'https://partners.shopify.com';
|
|
14
|
+
|
|
15
|
+
// The latest usage-charge accruals for an app, newest first, optionally
|
|
16
|
+
// scoped to one shop. Returns plain rows the callers stamp and reconcile
|
|
17
|
+
// with; throws on any GraphQL error — an unreadable ledger must never read
|
|
18
|
+
// as an empty one.
|
|
19
|
+
const getUsageChargeEvents = async ({ fetcher, appId, first = 10, occurredAtMin, organizationId, partnerToken, shopId }) => {
|
|
20
|
+
|
|
21
|
+
if( ! partnerToken || ! organizationId || ! appId ){
|
|
22
|
+
|
|
23
|
+
throw new Error( 'getUsageChargeEvents requires partnerToken, organizationId, and appId' );
|
|
24
|
+
|
|
25
|
+
}
|
|
26
|
+
const data = await request({
|
|
27
|
+
fetcher,
|
|
28
|
+
method : 'POST',
|
|
29
|
+
url : PARTNER_API + '/' + organizationId + '/api/' + PARTNER_API_VERSION + '/graphql.json',
|
|
30
|
+
headers : {
|
|
31
|
+
'X-Shopify-Access-Token' : partnerToken
|
|
32
|
+
},
|
|
33
|
+
body : {
|
|
34
|
+
query : `query usageCharges( $filter : EventFilterInput!, $first : Int! ) {
|
|
35
|
+
events( filter : $filter, orderBy : OCCURRED_AT_DESC, first : $first ) {
|
|
36
|
+
edges {
|
|
37
|
+
node {
|
|
38
|
+
id
|
|
39
|
+
occurredAt
|
|
40
|
+
eventType
|
|
41
|
+
shop { id myshopifyDomain }
|
|
42
|
+
... on Charge {
|
|
43
|
+
chargeId
|
|
44
|
+
chargeType
|
|
45
|
+
amount { amount currencyCode }
|
|
46
|
+
usageQuantity
|
|
47
|
+
planHandle
|
|
48
|
+
description
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
pageInfo { hasNextPage endCursor }
|
|
53
|
+
}
|
|
54
|
+
}`,
|
|
55
|
+
variables : {
|
|
56
|
+
filter : {
|
|
57
|
+
eventTypes : [ 'CHARGE_USAGE' ],
|
|
58
|
+
subjectId : String( appId ),
|
|
59
|
+
...( occurredAtMin && { occurredAtMin }),
|
|
60
|
+
...( shopId && { shopId : String( shopId ) })
|
|
61
|
+
},
|
|
62
|
+
first
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
if( data?.errors?.length ){
|
|
68
|
+
|
|
69
|
+
throw new Error( 'Shopify partner events query failed: ' + data.errors.map( ( entry ) => entry.message ).join( '; ' ) );
|
|
70
|
+
|
|
71
|
+
}
|
|
72
|
+
return ( data?.data?.events?.edges || [] ).map( ( edge ) => ({
|
|
73
|
+
amount : edge.node?.amount || null,
|
|
74
|
+
chargeId : edge.node?.chargeId || null,
|
|
75
|
+
// USAGE vs the recurring plan charge an approval emits — the
|
|
76
|
+
// disambiguator callers filter on.
|
|
77
|
+
chargeType : edge.node?.chargeType || null,
|
|
78
|
+
description : edge.node?.description || null,
|
|
79
|
+
eventType : edge.node?.eventType || null,
|
|
80
|
+
id : edge.node?.id || null,
|
|
81
|
+
occurredAt : edge.node?.occurredAt || null,
|
|
82
|
+
planHandle : edge.node?.planHandle || null,
|
|
83
|
+
shop : edge.node?.shop || null,
|
|
84
|
+
usageQuantity : edge.node?.usageQuantity ?? null
|
|
85
|
+
}) );
|
|
86
|
+
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
declare const shopifyPartner_getUsageChargeEvents: typeof getUsageChargeEvents;
|
|
90
|
+
declare namespace shopifyPartner {
|
|
91
|
+
export { shopifyPartner_getUsageChargeEvents as getUsageChargeEvents };
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export { getUsageChargeEvents as g, shopifyPartner as s };
|