atmn 1.1.19 → 1.1.20
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/cli.js +79 -28
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -45772,30 +45772,16 @@ async function startCallbackServer(port, onCallback, onListening) {
|
|
|
45772
45772
|
server.listen(port, onListening);
|
|
45773
45773
|
});
|
|
45774
45774
|
}
|
|
45775
|
+
function buildCliOAuthScopes() {
|
|
45776
|
+
return CLI_SCOPE_REQUESTS.flatMap(({ resource, actions }) => actions.map((action) => `${resource}:${action}`));
|
|
45777
|
+
}
|
|
45775
45778
|
async function startOAuthFlow(clientId, options) {
|
|
45776
45779
|
const codeVerifier = generateCodeVerifier();
|
|
45777
45780
|
const state = generateState();
|
|
45778
45781
|
for (const port of OAUTH_PORTS) {
|
|
45779
45782
|
const redirectUri = getOAuthRedirectUri(port);
|
|
45780
45783
|
const client = new OAuth2Client(clientId, null, redirectUri);
|
|
45781
|
-
const authUrl = client.createAuthorizationURLWithPKCE(getAuthorizationEndpoint(), state, CodeChallengeMethod.S256, codeVerifier,
|
|
45782
|
-
...[
|
|
45783
|
-
{
|
|
45784
|
-
resource: "customers",
|
|
45785
|
-
actions: ["create", "read", "list", "update", "delete"]
|
|
45786
|
-
},
|
|
45787
|
-
{
|
|
45788
|
-
resource: "features",
|
|
45789
|
-
actions: ["create", "read", "list", "update", "delete"]
|
|
45790
|
-
},
|
|
45791
|
-
{
|
|
45792
|
-
resource: "plans",
|
|
45793
|
-
actions: ["create", "read", "list", "update", "delete"]
|
|
45794
|
-
},
|
|
45795
|
-
{ resource: "apiKeys", actions: ["create", "read"] },
|
|
45796
|
-
{ resource: "organisation", actions: ["read"] }
|
|
45797
|
-
].flatMap(({ resource, actions }) => actions.map((action) => `${resource}:${action}`))
|
|
45798
|
-
]);
|
|
45784
|
+
const authUrl = client.createAuthorizationURLWithPKCE(getAuthorizationEndpoint(), state, CodeChallengeMethod.S256, codeVerifier, buildCliOAuthScopes());
|
|
45799
45785
|
authUrl.searchParams.set("prompt", "consent");
|
|
45800
45786
|
const result2 = await startCallbackServer(port, async (url) => {
|
|
45801
45787
|
const error = url.searchParams.get("error");
|
|
@@ -45872,12 +45858,29 @@ async function getApiKeysWithToken(accessToken) {
|
|
|
45872
45858
|
orgId: data.org_id
|
|
45873
45859
|
};
|
|
45874
45860
|
}
|
|
45875
|
-
var getAuthorizationEndpoint = () => `${getBackendUrl()}/api/auth/oauth2/authorize`, getTokenEndpoint = () => `${getBackendUrl()}/api/auth/oauth2/token
|
|
45861
|
+
var getAuthorizationEndpoint = () => `${getBackendUrl()}/api/auth/oauth2/authorize`, getTokenEndpoint = () => `${getBackendUrl()}/api/auth/oauth2/token`, CLI_SCOPE_REQUESTS;
|
|
45876
45862
|
var init_oauth = __esm(() => {
|
|
45877
45863
|
init_dist8();
|
|
45878
45864
|
init_open();
|
|
45879
45865
|
init_backendUrl();
|
|
45880
45866
|
init_constants();
|
|
45867
|
+
CLI_SCOPE_REQUESTS = [
|
|
45868
|
+
{
|
|
45869
|
+
resource: "customers",
|
|
45870
|
+
actions: ["create", "read", "list", "update", "delete"]
|
|
45871
|
+
},
|
|
45872
|
+
{
|
|
45873
|
+
resource: "features",
|
|
45874
|
+
actions: ["create", "read", "list", "update", "delete"]
|
|
45875
|
+
},
|
|
45876
|
+
{
|
|
45877
|
+
resource: "plans",
|
|
45878
|
+
actions: ["create", "read", "list", "update", "delete"]
|
|
45879
|
+
},
|
|
45880
|
+
{ resource: "rewards", actions: ["read", "write"] },
|
|
45881
|
+
{ resource: "apiKeys", actions: ["create", "read"] },
|
|
45882
|
+
{ resource: "organisation", actions: ["read"] }
|
|
45883
|
+
];
|
|
45881
45884
|
});
|
|
45882
45885
|
|
|
45883
45886
|
// src/lib/api/client.ts
|
|
@@ -47152,7 +47155,7 @@ function parseExistingConfig({
|
|
|
47152
47155
|
}
|
|
47153
47156
|
if (trimmed.startsWith("import ")) {
|
|
47154
47157
|
const startLine = i;
|
|
47155
|
-
while (i < lines.length &&
|
|
47158
|
+
while (i < lines.length && !/(?:["'];?|;)\s*(?:\/\/.*|\/\*.*)?$/.test(lines[i])) {
|
|
47156
47159
|
i++;
|
|
47157
47160
|
}
|
|
47158
47161
|
const endLine = i;
|
|
@@ -47205,7 +47208,7 @@ function parseExistingConfig({
|
|
|
47205
47208
|
depth--;
|
|
47206
47209
|
}
|
|
47207
47210
|
}
|
|
47208
|
-
if (foundStart && depth === 0
|
|
47211
|
+
if (foundStart && depth === 0) {
|
|
47209
47212
|
break;
|
|
47210
47213
|
}
|
|
47211
47214
|
i++;
|
|
@@ -48483,7 +48486,7 @@ var init_pull = __esm(() => {
|
|
|
48483
48486
|
});
|
|
48484
48487
|
|
|
48485
48488
|
// src/lib/version.ts
|
|
48486
|
-
var APP_VERSION = "1.1.
|
|
48489
|
+
var APP_VERSION = "1.1.20";
|
|
48487
48490
|
|
|
48488
48491
|
// ../../node_modules/.bun/@tanstack+query-core@5.101.1/node_modules/@tanstack/query-core/build/modern/subscribable.js
|
|
48489
48492
|
var Subscribable = class {
|
|
@@ -105929,7 +105932,7 @@ var init_usageLimit = __esm(() => {
|
|
|
105929
105932
|
exports_external.string().min(1).max(USAGE_LIMIT_FILTER_MAX_VALUE_LENGTH),
|
|
105930
105933
|
exports_external.number(),
|
|
105931
105934
|
exports_external.boolean()
|
|
105932
|
-
]).transform(String);
|
|
105935
|
+
]).transform(String).pipe(exports_external.string());
|
|
105933
105936
|
UsageLimitFilterSchema = exports_external.object({
|
|
105934
105937
|
properties: exports_external.record(exports_external.string().min(1).max(USAGE_LIMIT_FILTER_MAX_KEY_LENGTH), UsageLimitFilterValueSchema).meta({
|
|
105935
105938
|
description: "Event property equality conditions. A usage event counts toward this cap only when every listed property matches (AND)."
|
|
@@ -121538,7 +121541,7 @@ var init_eventsAggregateResponseV0 = __esm(() => {
|
|
|
121538
121541
|
});
|
|
121539
121542
|
|
|
121540
121543
|
// ../../shared/api/events/aggregate/eventsAggregateResponseV1.ts
|
|
121541
|
-
var EventAggregateListItemV1Schema, EventAggregateTotalItemSchema, EventsAggregateResponseV1Schema;
|
|
121544
|
+
var EventAggregateListItemV1Schema, EventAggregateTotalItemSchema, DeductionBalanceSchema, DeductionFeatureSchema, DeductionPeriodSchema, EventsAggregateResponseV1Schema;
|
|
121542
121545
|
var init_eventsAggregateResponseV1 = __esm(() => {
|
|
121543
121546
|
init_v4();
|
|
121544
121547
|
EventAggregateListItemV1Schema = exports_external.object({
|
|
@@ -121556,12 +121559,57 @@ var init_eventsAggregateResponseV1 = __esm(() => {
|
|
|
121556
121559
|
count: exports_external.number().meta({ description: "Number of events for this feature" }),
|
|
121557
121560
|
sum: exports_external.number().meta({ description: "Sum of event values for this feature" })
|
|
121558
121561
|
});
|
|
121562
|
+
DeductionBalanceSchema = exports_external.object({
|
|
121563
|
+
balance_id: exports_external.string().meta({
|
|
121564
|
+
description: "ID of the balance row drawn from (customer_entitlement or rollover)."
|
|
121565
|
+
}),
|
|
121566
|
+
entity_id: exports_external.string().nullable().meta({
|
|
121567
|
+
description: "Entity that owns this balance, or null when it is customer-level and shared."
|
|
121568
|
+
}),
|
|
121569
|
+
plan_id: exports_external.string().nullable().meta({
|
|
121570
|
+
description: "Plan the balance came with. Null for balances created outside a plan."
|
|
121571
|
+
}),
|
|
121572
|
+
reset: exports_external.object({
|
|
121573
|
+
interval: exports_external.string(),
|
|
121574
|
+
resets_at: exports_external.number().nullable()
|
|
121575
|
+
}).nullable().meta({ description: "Reset config for this balance, captured at deduction time." }),
|
|
121576
|
+
credit_cost: exports_external.number().nullable().meta({
|
|
121577
|
+
description: "Multiplier applied converting the tracked feature into this balance. Null when 1:1, or when the query spans sources converting at different rates."
|
|
121578
|
+
}),
|
|
121579
|
+
deducted: exports_external.number(),
|
|
121580
|
+
events: exports_external.number()
|
|
121581
|
+
});
|
|
121582
|
+
DeductionFeatureSchema = exports_external.object({
|
|
121583
|
+
feature_type: exports_external.enum(["metered", "credit_system"]).meta({
|
|
121584
|
+
description: "credit_system means `deducted` is credits; metered means it is that feature's own amount."
|
|
121585
|
+
}),
|
|
121586
|
+
deducted: exports_external.number(),
|
|
121587
|
+
events: exports_external.number(),
|
|
121588
|
+
balances: exports_external.array(DeductionBalanceSchema)
|
|
121589
|
+
});
|
|
121590
|
+
DeductionPeriodSchema = exports_external.object({
|
|
121591
|
+
period: exports_external.number().meta({
|
|
121592
|
+
description: "Unix timestamp (epoch ms), same basis as `list`."
|
|
121593
|
+
}),
|
|
121594
|
+
values: exports_external.record(exports_external.string(), DeductionFeatureSchema).meta({
|
|
121595
|
+
description: "Keyed by the feature that OWNS the balance drawn from, not the feature that was tracked."
|
|
121596
|
+
}),
|
|
121597
|
+
grouped_values: exports_external.record(exports_external.string(), exports_external.record(exports_external.string(), exports_external.object({
|
|
121598
|
+
deducted: exports_external.number(),
|
|
121599
|
+
credit_cost: exports_external.number().nullable().optional()
|
|
121600
|
+
}))).optional().meta({
|
|
121601
|
+
description: "Present only when group_by is used. Keyed by balance_id, then by group value — the only way to attribute a shared balance to the entity that spent from it."
|
|
121602
|
+
})
|
|
121603
|
+
});
|
|
121559
121604
|
EventsAggregateResponseV1Schema = exports_external.object({
|
|
121560
121605
|
list: exports_external.array(EventAggregateListItemV1Schema).meta({
|
|
121561
121606
|
description: "Array of time periods with aggregated values"
|
|
121562
121607
|
}),
|
|
121563
121608
|
total: exports_external.record(exports_external.string(), EventAggregateTotalItemSchema).meta({
|
|
121564
121609
|
description: "Total aggregations per feature. Keys are feature IDs, values contain count and sum."
|
|
121610
|
+
}),
|
|
121611
|
+
deductions: exports_external.array(DeductionPeriodSchema).optional().meta({
|
|
121612
|
+
description: 'Per-balance breakdown of what was consumed. Present only when aggregate_on is "deducted".'
|
|
121565
121613
|
})
|
|
121566
121614
|
});
|
|
121567
121615
|
});
|
|
@@ -126536,6 +126584,9 @@ var init_eventsAggregateParams = __esm(() => {
|
|
|
126536
126584
|
}),
|
|
126537
126585
|
max_groups: exports_external.number().int().min(1).max(250).optional().meta({
|
|
126538
126586
|
description: "Maximum number of distinct group values to return per time bin when using group_by. Remaining values are bundled into an 'Other' bucket. Defaults to 9"
|
|
126587
|
+
}),
|
|
126588
|
+
aggregate_on: exports_external.enum(["deducted"]).optional().meta({
|
|
126589
|
+
description: 'Set to "deducted" to additionally return a per-balance breakdown of what each event consumed, under `deductions`. Purely additive: `list` and `total` are unchanged. Requires customer_id.'
|
|
126539
126590
|
})
|
|
126540
126591
|
});
|
|
126541
126592
|
EventsAggregateParamsSchema = ExtEventsAggregateParamsSchema.refine((data) => {
|
|
@@ -133860,7 +133911,7 @@ var init_error3 = __esm(() => {
|
|
|
133860
133911
|
};
|
|
133861
133912
|
});
|
|
133862
133913
|
|
|
133863
|
-
// ../../node_modules/.bun/better-auth@1.6.25+
|
|
133914
|
+
// ../../node_modules/.bun/better-auth@1.6.25+fdfecc926c70e080/node_modules/better-auth/dist/plugins/access/access.mjs
|
|
133864
133915
|
function unknownResourceResponse(requestedResource) {
|
|
133865
133916
|
return {
|
|
133866
133917
|
success: false,
|
|
@@ -133949,12 +134000,12 @@ var init_access = __esm(() => {
|
|
|
133949
134000
|
init_error3();
|
|
133950
134001
|
});
|
|
133951
134002
|
|
|
133952
|
-
// ../../node_modules/.bun/better-auth@1.6.25+
|
|
134003
|
+
// ../../node_modules/.bun/better-auth@1.6.25+fdfecc926c70e080/node_modules/better-auth/dist/plugins/access/index.mjs
|
|
133953
134004
|
var init_access2 = __esm(() => {
|
|
133954
134005
|
init_access();
|
|
133955
134006
|
});
|
|
133956
134007
|
|
|
133957
|
-
// ../../node_modules/.bun/better-auth@1.6.25+
|
|
134008
|
+
// ../../node_modules/.bun/better-auth@1.6.25+fdfecc926c70e080/node_modules/better-auth/dist/plugins/organization/access/statement.mjs
|
|
133958
134009
|
var defaultStatements, defaultAc, adminAc, ownerAc, memberAc;
|
|
133959
134010
|
var init_statement = __esm(() => {
|
|
133960
134011
|
init_access();
|
|
@@ -134028,7 +134079,7 @@ var init_statement = __esm(() => {
|
|
|
134028
134079
|
});
|
|
134029
134080
|
});
|
|
134030
134081
|
|
|
134031
|
-
// ../../node_modules/.bun/better-auth@1.6.25+
|
|
134082
|
+
// ../../node_modules/.bun/better-auth@1.6.25+fdfecc926c70e080/node_modules/better-auth/dist/plugins/organization/access/index.mjs
|
|
134032
134083
|
var init_access3 = __esm(() => {
|
|
134033
134084
|
init_statement();
|
|
134034
134085
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "atmn",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.20",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"bin": {
|
|
6
6
|
"atmn": "dist/cli.js"
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"build": "bun run bun.config.ts",
|
|
35
35
|
"dev": "nodemon -e ts,tsx --watch src --ignore dist --exec \"bun run bun.config.ts\"",
|
|
36
36
|
"dev:bun": "bun run dev.ts",
|
|
37
|
-
"test": "bun test test/*.test.ts test/codegen test/nuke test/pull test/push test/workflow",
|
|
37
|
+
"test": "bun test test/*.test.ts test/auth test/codegen test/nuke test/pull test/push test/workflow",
|
|
38
38
|
"test:integration": "cd ../../server && ENV_FILE=.env infisical run --env=dev --recursive -- bun test --timeout 0 ../packages/atmn/test/integration",
|
|
39
39
|
"test:integration:cli": "cd ../../server && ENV_FILE=.env infisical run --env=dev --recursive -- bun ../packages/atmn/test/integration/cli.ts",
|
|
40
40
|
"test:unit": "bun test test/codegen",
|