meterflow 0.1.0

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.
@@ -0,0 +1,14 @@
1
+ import type { MeterFlow } from "../client";
2
+ import type { components } from "../types/openapi";
3
+ type PlanResponse = components["schemas"]["PlanResponse"];
4
+ export interface ListQuery {
5
+ project_id?: string;
6
+ }
7
+ export declare class PlansResource {
8
+ private readonly client;
9
+ constructor(client: MeterFlow);
10
+ list(query?: ListQuery): Promise<PlanResponse[]>;
11
+ get(planId: string, query?: ListQuery): Promise<PlanResponse>;
12
+ }
13
+ export {};
14
+ //# sourceMappingURL=plans.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plans.d.ts","sourceRoot":"","sources":["../../../src/resources/plans.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD,KAAK,YAAY,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC,cAAc,CAAC,CAAC;AAE1D,MAAM,WAAW,SAAS;IACxB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,qBAAa,aAAa;IACZ,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,SAAS;IAE9C,IAAI,CAAC,KAAK,CAAC,EAAE,SAAS,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC;IAMhD,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,SAAS,GAAG,OAAO,CAAC,YAAY,CAAC;CAK9D"}
@@ -0,0 +1,24 @@
1
+ import type { MeterFlow } from "../client";
2
+ import type { components } from "../types/openapi";
3
+ type SubscriptionCreateRequest = components["schemas"]["SubscriptionCreateRequest"];
4
+ type SubscriptionUpdateRequest = components["schemas"]["SubscriptionUpdateRequest"];
5
+ type SubscriptionResponse = components["schemas"]["SubscriptionResponse"];
6
+ export interface CreateOptions {
7
+ idempotencyKey?: string;
8
+ }
9
+ export interface ListQuery {
10
+ customer_id?: string;
11
+ }
12
+ export declare class SubscriptionsResource {
13
+ private readonly client;
14
+ constructor(client: MeterFlow);
15
+ create(body: SubscriptionCreateRequest, opts?: CreateOptions): Promise<SubscriptionResponse>;
16
+ list(query?: ListQuery): Promise<SubscriptionResponse[]>;
17
+ get(subscriptionId: string): Promise<SubscriptionResponse>;
18
+ update(subscriptionId: string, body: SubscriptionUpdateRequest, opts?: {
19
+ idempotencyKey?: string;
20
+ }): Promise<SubscriptionResponse>;
21
+ delete(subscriptionId: string): Promise<void>;
22
+ }
23
+ export {};
24
+ //# sourceMappingURL=subscriptions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subscriptions.d.ts","sourceRoot":"","sources":["../../../src/resources/subscriptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD,KAAK,yBAAyB,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC,2BAA2B,CAAC,CAAC;AACpF,KAAK,yBAAyB,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC,2BAA2B,CAAC,CAAC;AACpF,KAAK,oBAAoB,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC,sBAAsB,CAAC,CAAC;AAE1E,MAAM,WAAW,aAAa;IAC5B,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,SAAS;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,qBAAa,qBAAqB;IACpB,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,SAAS;IAE9C,MAAM,CAAC,IAAI,EAAE,yBAAyB,EAAE,IAAI,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAO5F,IAAI,CAAC,KAAK,CAAC,EAAE,SAAS,GAAG,OAAO,CAAC,oBAAoB,EAAE,CAAC;IAMxD,GAAG,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAI1D,MAAM,CAAC,cAAc,EAAE,MAAM,EAAE,IAAI,EAAE,yBAAyB,EAAE,IAAI,CAAC,EAAE;QAAE,cAAc,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAOlI,MAAM,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAG9C"}
@@ -0,0 +1,22 @@
1
+ import type { MeterFlow } from "../client";
2
+ import type { components } from "../types/openapi";
3
+ type UsageEventRequest = components["schemas"]["UsageEventRequest"];
4
+ type UsageEventResponse = components["schemas"]["UsageEventResponse"];
5
+ type UsageSummaryResponse = components["schemas"]["UsageSummaryResponse"];
6
+ export interface RecordOptions {
7
+ idempotencyKey?: string;
8
+ }
9
+ export interface SummaryQuery {
10
+ meter_id?: string;
11
+ from_?: string;
12
+ to?: string;
13
+ }
14
+ export declare class UsageResource {
15
+ private readonly client;
16
+ constructor(client: MeterFlow);
17
+ record(body: UsageEventRequest, opts?: RecordOptions): Promise<UsageEventResponse>;
18
+ recordBatch(events: UsageEventRequest[], opts?: RecordOptions): Promise<UsageEventResponse[]>;
19
+ summary(customerId: string, query?: SummaryQuery): Promise<UsageSummaryResponse>;
20
+ }
21
+ export {};
22
+ //# sourceMappingURL=usage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usage.d.ts","sourceRoot":"","sources":["../../../src/resources/usage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD,KAAK,iBAAiB,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC,mBAAmB,CAAC,CAAC;AACpE,KAAK,kBAAkB,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC,oBAAoB,CAAC,CAAC;AACtE,KAAK,oBAAoB,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC,sBAAsB,CAAC,CAAC;AAE1E,MAAM,WAAW,aAAa;IAC5B,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,EAAE,CAAC,EAAE,MAAM,CAAC;CACb;AAED,qBAAa,aAAa;IACZ,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,SAAS;IAE9C,MAAM,CAAC,IAAI,EAAE,iBAAiB,EAAE,IAAI,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAOlF,WAAW,CAAC,MAAM,EAAE,iBAAiB,EAAE,EAAE,IAAI,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,kBAAkB,EAAE,CAAC;IAO7F,OAAO,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,oBAAoB,CAAC;CAKjF"}
@@ -0,0 +1,3 @@
1
+ import type { MeterFlowOptions, RequestOptions } from "../client";
2
+ export declare function httpRequest<T>(options: Required<MeterFlowOptions>, method: string, path: string, opts?: RequestOptions): Promise<T>;
3
+ //# sourceMappingURL=http.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../../src/utils/http.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAiElE,wBAAsB,WAAW,CAAC,CAAC,EACjC,OAAO,EAAE,QAAQ,CAAC,gBAAgB,CAAC,EACnC,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,IAAI,CAAC,EAAE,cAAc,GACpB,OAAO,CAAC,CAAC,CAAC,CAgCZ"}
@@ -0,0 +1,8 @@
1
+ export interface RetryOptions {
2
+ retries: number;
3
+ factor: number;
4
+ jitter: boolean;
5
+ maxDelayMs: number;
6
+ }
7
+ export declare function retryable<T>(fn: () => Promise<T>, opts: RetryOptions, shouldRetry?: (err: unknown) => boolean): Promise<T>;
8
+ //# sourceMappingURL=retry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"retry.d.ts","sourceRoot":"","sources":["../../../src/utils/retry.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,OAAO,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;CACpB;AAMD,wBAAsB,SAAS,CAAC,CAAC,EAC/B,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EACpB,IAAI,EAAE,YAAY,EAClB,WAAW,GAAE,CAAC,GAAG,EAAE,OAAO,KAAK,OAA6B,GAC3D,OAAO,CAAC,CAAC,CAAC,CA2BZ"}
@@ -0,0 +1,2 @@
1
+ export declare function verifyWebhook(rawBody: string | Buffer, signature: string, secret: string): boolean;
2
+ //# sourceMappingURL=webhook-verify.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webhook-verify.d.ts","sourceRoot":"","sources":["../../../src/utils/webhook-verify.ts"],"names":[],"mappings":"AAEA,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAOlG"}
@@ -0,0 +1,3 @@
1
+ declare const _default: import("vite").UserConfig;
2
+ export default _default;
3
+ //# sourceMappingURL=vitest.config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vitest.config.d.ts","sourceRoot":"","sources":["../vitest.config.ts"],"names":[],"mappings":";AAEA,wBAkBG"}
package/package.json ADDED
@@ -0,0 +1,60 @@
1
+ {
2
+ "name": "meterflow",
3
+ "version": "0.1.0",
4
+ "description": "Official Node.js SDK for MeterFlow — usage-based billing, credit management, and metering.",
5
+ "license": "MIT",
6
+ "author": "MeterFlow",
7
+ "homepage": "https://github.com/meterflowio/meterflow-node",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "https://github.com/meterflowio/meterflow-node.git"
11
+ },
12
+ "engines": {
13
+ "node": ">=18"
14
+ },
15
+ "main": "dist/index.cjs",
16
+ "module": "dist/index.mjs",
17
+ "types": "dist/index.d.ts",
18
+ "exports": {
19
+ ".": {
20
+ "import": "./dist/index.mjs",
21
+ "require": "./dist/index.cjs",
22
+ "types": "./dist/index.d.ts"
23
+ }
24
+ },
25
+ "files": [
26
+ "dist"
27
+ ],
28
+ "scripts": {
29
+ "build": "tsc --project tsconfig.json --emitDeclarationOnly && node scripts/build-fix.mjs && esbuild src/index.ts --bundle --platform=node --format=esm --outfile=dist/index.mjs && esbuild src/index.ts --bundle --platform=node --format=cjs --outfile=dist/index.cjs && node -e \"require('fs').copyFileSync('dist/index.cjs','dist/index.js')\"",
30
+ "dev": "tsc --project tsconfig.json --watch",
31
+ "quickstart": "npm run build && npx tsx examples/quickstart.ts",
32
+ "typecheck": "tsc --noEmit",
33
+ "lint": "eslint src tests",
34
+ "lint:fix": "eslint src tests --fix",
35
+ "format": "prettier --write src tests",
36
+ "format:check": "prettier --check src tests",
37
+ "test": "vitest run",
38
+ "test:watch": "vitest",
39
+ "test:coverage": "vitest run --coverage",
40
+ "generate:types": "openapi-typescript ../../docs/openapi.json -o src/types/openapi.d.ts",
41
+ "ci:types-check": "npm run generate:types && git diff --exit-code src/types/openapi.d.ts"
42
+ },
43
+ "devDependencies": {
44
+ "@rollup/plugin-node-resolve": "^15.2.3",
45
+ "esbuild": "^0.25.0",
46
+ "@types/node": "^18.19.130",
47
+ "@typescript-eslint/eslint-plugin": "^7.0.0",
48
+ "@typescript-eslint/parser": "^7.0.0",
49
+ "@vitest/coverage-v8": "^1.6.0",
50
+ "eslint": "^8.57.0",
51
+ "msw": "^2.3.0",
52
+ "openapi-typescript": "^7.0.0",
53
+ "prettier": "^3.3.0",
54
+ "rollup": "^4.18.0",
55
+ "rollup-plugin-dts": "^6.1.0",
56
+ "rollup-plugin-typescript2": "^0.36.0",
57
+ "typescript": "^5.5.0",
58
+ "vitest": "^1.6.0"
59
+ }
60
+ }