@distilled.cloud/supabase 0.15.2 → 0.16.1
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/lib/client.d.ts.map +1 -1
- package/lib/client.js +8 -1
- package/lib/client.js.map +1 -1
- package/lib/errors.d.ts +9 -0
- package/lib/errors.d.ts.map +1 -1
- package/lib/errors.js +12 -0
- package/lib/errors.js.map +1 -1
- package/package.json +3 -3
- package/src/client.ts +10 -0
- package/src/errors.ts +15 -0
package/lib/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAUxC,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AA0C/C;;GAEG;AACH,eAAO,MAAM,GAAG;;;CAQd,CAAC"}
|
package/lib/client.js
CHANGED
|
@@ -8,7 +8,7 @@ import * as Effect from "effect/Effect";
|
|
|
8
8
|
import * as Redacted from "effect/Redacted";
|
|
9
9
|
import * as Schema from "effect/Schema";
|
|
10
10
|
import { makeAPI } from "@distilled.cloud/core/client";
|
|
11
|
-
import { HTTP_STATUS_MAP, UnknownSupabaseError, SupabaseParseError, } from "./errors.js";
|
|
11
|
+
import { HTTP_STATUS_MAP, UnknownSupabaseError, SupabaseParseError, FreeProjectLimitReached, } from "./errors.js";
|
|
12
12
|
// Re-export for backwards compatibility
|
|
13
13
|
export { UnknownSupabaseError } from "./errors.js";
|
|
14
14
|
import { Credentials } from "./credentials.js";
|
|
@@ -22,6 +22,13 @@ const ApiErrorResponse = Schema.Struct({
|
|
|
22
22
|
const matchError = (status, errorBody) => {
|
|
23
23
|
try {
|
|
24
24
|
const parsed = Schema.decodeUnknownSync(ApiErrorResponse)(errorBody);
|
|
25
|
+
// Supabase has no error code on the wire; the only signal for the
|
|
26
|
+
// free-tier active-project limit is a literal substring of the message.
|
|
27
|
+
// Detect it before falling through to the generic status-code map so
|
|
28
|
+
// tests and callers can react to it as a typed error.
|
|
29
|
+
if (parsed.message?.includes("active free projects")) {
|
|
30
|
+
return Effect.fail(new FreeProjectLimitReached({ message: parsed.message }));
|
|
31
|
+
}
|
|
25
32
|
// Supabase returns 406 for some "not found" conditions (e.g. snippets)
|
|
26
33
|
const effectiveStatus = status === 406 ? 404 : status;
|
|
27
34
|
const ErrorClass = HTTP_STATUS_MAP[effectiveStatus];
|
package/lib/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAC5C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,8BAA8B,CAAC;AACvD,OAAO,EACL,eAAe,EACf,oBAAoB,EACpB,kBAAkB,
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAC5C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,8BAA8B,CAAC;AACvD,OAAO,EACL,eAAe,EACf,oBAAoB,EACpB,kBAAkB,EAClB,uBAAuB,GACxB,MAAM,aAAa,CAAC;AAErB,wCAAwC;AACxC,OAAO,EAAE,oBAAoB,EAAE,MA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IACpE,CAAC;AACH,CAAC,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,GAAG,GAAG,OAAO,CAAc;IACtC,WAAW,EAAE,WAAkB;IAC/B,UAAU,EAAE,CAAC,KAAU,EAAE,EAAE,CAAC,KAAK,CAAC,UAAU;IAC5C,cAAc,EAAE,CAAC,KAAU,EAAE,EAAE,CAAC,CAAC;QAC/B,aAAa,EAAE,UAAU,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,EAAE;KAC7D,CAAC;IACF,UAAU;IACV,UAAU,EAAE,kBAAyB;CACtC,CAAC,CAAC"}
|
package/lib/errors.d.ts
CHANGED
|
@@ -18,6 +18,15 @@ declare const UnknownSupabaseError_base: Schema.Class<UnknownSupabaseError, Sche
|
|
|
18
18
|
});
|
|
19
19
|
export declare class UnknownSupabaseError extends UnknownSupabaseError_base {
|
|
20
20
|
}
|
|
21
|
+
declare const FreeProjectLimitReached_base: Schema.Class<FreeProjectLimitReached, Schema.TaggedStruct<"FreeProjectLimitReached", {
|
|
22
|
+
readonly message: Schema.String;
|
|
23
|
+
}>, import("effect/Cause").YieldableError> & (new (...args: any[]) => {
|
|
24
|
+
"@distilled.cloud/error/categories": {
|
|
25
|
+
QuotaError: true;
|
|
26
|
+
};
|
|
27
|
+
});
|
|
28
|
+
export declare class FreeProjectLimitReached extends FreeProjectLimitReached_base {
|
|
29
|
+
}
|
|
21
30
|
declare const SupabaseParseError_base: Schema.Class<SupabaseParseError, Schema.TaggedStruct<"SupabaseParseError", {
|
|
22
31
|
readonly body: Schema.Unknown;
|
|
23
32
|
readonly cause: Schema.Unknown;
|
package/lib/errors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EACL,UAAU,EACV,UAAU,EACV,QAAQ,EACR,WAAW,EACX,SAAS,EACT,cAAc,EACd,mBAAmB,EACnB,MAAM,EACN,QAAQ,EACR,kBAAkB,EAClB,eAAe,EACf,YAAY,EACZ,mBAAmB,EACnB,eAAe,EACf,cAAc,EACd,UAAU,GACX,MAAM,8BAA8B,CAAC;AACtC,YAAY,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAElE,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;;;;;;;;;;AAIxC,qBAAa,oBAAqB,SAAQ,yBAOV;CAAG;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EACL,UAAU,EACV,UAAU,EACV,QAAQ,EACR,WAAW,EACX,SAAS,EACT,cAAc,EACd,mBAAmB,EACnB,MAAM,EACN,QAAQ,EACR,kBAAkB,EAClB,eAAe,EACf,YAAY,EACZ,mBAAmB,EACnB,eAAe,EACf,cAAc,EACd,UAAU,GACX,MAAM,8BAA8B,CAAC;AACtC,YAAY,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAElE,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;;;;;;;;;;AAIxC,qBAAa,oBAAqB,SAAQ,yBAOV;CAAG;;;;;;;;AAUnC,qBAAa,uBAAwB,SAAQ,4BAKd;CAAG;;;;;;;;;AAGlC,qBAAa,kBAAmB,SAAQ,uBAMT;CAAG"}
|
package/lib/errors.js
CHANGED
|
@@ -14,6 +14,18 @@ export class UnknownSupabaseError extends Schema.TaggedErrorClass()("UnknownSupa
|
|
|
14
14
|
body: Schema.Unknown,
|
|
15
15
|
}).pipe(Category.withServerError) {
|
|
16
16
|
}
|
|
17
|
+
// Returned when v1CreateAProject is called against an org whose owner has
|
|
18
|
+
// already hit the free-tier active-project ceiling (currently 2). Supabase
|
|
19
|
+
// surfaces this as a generic 4xx with the literal message
|
|
20
|
+
// "The following organization members have reached their maximum limits
|
|
21
|
+
// for the number of active free projects within organizations where
|
|
22
|
+
// they are an administrator or owner: <email> (<n> project limit)..."
|
|
23
|
+
// We tag it explicitly so tests can detect it, clean up stale projects,
|
|
24
|
+
// and retry — and so callers can distinguish it from a real BadRequest.
|
|
25
|
+
export class FreeProjectLimitReached extends Schema.TaggedErrorClass()("FreeProjectLimitReached", {
|
|
26
|
+
message: Schema.String,
|
|
27
|
+
}).pipe(Category.withQuotaError) {
|
|
28
|
+
}
|
|
17
29
|
// Schema parse error wrapper
|
|
18
30
|
export class SupabaseParseError extends Schema.TaggedErrorClass()("SupabaseParseError", {
|
|
19
31
|
body: Schema.Unknown,
|
package/lib/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EACL,UAAU,EACV,UAAU,EACV,QAAQ,EACR,WAAW,EACX,SAAS,EACT,cAAc,EACd,mBAAmB,EACnB,MAAM,EACN,QAAQ,EACR,kBAAkB,EAClB,eAAe,EACf,YAAY,EACZ,mBAAmB,EACnB,eAAe,EACf,cAAc,EACd,UAAU,GACX,MAAM,8BAA8B,CAAC;AAGtC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,QAAQ,MAAM,gCAAgC,CAAC;AAE3D,yEAAyE;AACzE,MAAM,OAAO,oBAAqB,SAAQ,MAAM,CAAC,gBAAgB,EAAwB,CACvF,sBAAsB,EACtB;IACE,IAAI,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC;IACpC,OAAO,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC;IACvC,IAAI,EAAE,MAAM,CAAC,OAAO;CACrB,CACF,CAAC,IAAI,CAAC,QAAQ,CAAC,eAAe,CAAC;CAAG;AAEnC,6BAA6B;AAC7B,MAAM,OAAO,kBAAmB,SAAQ,MAAM,CAAC,gBAAgB,EAAsB,CACnF,oBAAoB,EACpB;IACE,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,CACnF,oBAAoB,EACpB;IACE,IAAI,EAAE,MAAM,CAAC,OAAO;IACpB,KAAK,EAAE,MAAM,CAAC,OAAO;CACtB,CACF,CAAC,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC;CAAG"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@distilled.cloud/supabase",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.1",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/alchemy-run/distilled",
|
|
@@ -67,14 +67,14 @@
|
|
|
67
67
|
"lint": "oxlint --fix src",
|
|
68
68
|
"check": "tsgo && oxlint src && oxfmt --check src",
|
|
69
69
|
"nuke": "bun scripts/nuke.ts",
|
|
70
|
-
"test": "bunx vitest run test --exclude specs",
|
|
70
|
+
"test": "bunx vitest run test --exclude specs --passWithNoTests",
|
|
71
71
|
"publish:npm": "bun run build && bun publish --access public",
|
|
72
72
|
"generate": "bun run scripts/generate.ts && oxlint --fix src && oxfmt --write src && oxfmt --write src",
|
|
73
73
|
"specs:fetch": "git submodule update --force --init --recursive --depth=1 specs/distilled-spec-supabase && git -C specs/distilled-spec-supabase checkout -- .",
|
|
74
74
|
"specs:update": "git -C specs/distilled-spec-supabase fetch && git -C specs/distilled-spec-supabase checkout main && git -C specs/distilled-spec-supabase pull"
|
|
75
75
|
},
|
|
76
76
|
"dependencies": {
|
|
77
|
-
"@distilled.cloud/core": "0.
|
|
77
|
+
"@distilled.cloud/core": "0.16.1",
|
|
78
78
|
"effect": "4.0.0-beta.58"
|
|
79
79
|
},
|
|
80
80
|
"devDependencies": {
|
package/src/client.ts
CHANGED
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
HTTP_STATUS_MAP,
|
|
13
13
|
UnknownSupabaseError,
|
|
14
14
|
SupabaseParseError,
|
|
15
|
+
FreeProjectLimitReached,
|
|
15
16
|
} from "./errors.ts";
|
|
16
17
|
|
|
17
18
|
// Re-export for backwards compatibility
|
|
@@ -32,6 +33,15 @@ const matchError = (
|
|
|
32
33
|
): Effect.Effect<never, unknown> => {
|
|
33
34
|
try {
|
|
34
35
|
const parsed = Schema.decodeUnknownSync(ApiErrorResponse)(errorBody);
|
|
36
|
+
// Supabase has no error code on the wire; the only signal for the
|
|
37
|
+
// free-tier active-project limit is a literal substring of the message.
|
|
38
|
+
// Detect it before falling through to the generic status-code map so
|
|
39
|
+
// tests and callers can react to it as a typed error.
|
|
40
|
+
if (parsed.message?.includes("active free projects")) {
|
|
41
|
+
return Effect.fail(
|
|
42
|
+
new FreeProjectLimitReached({ message: parsed.message }),
|
|
43
|
+
);
|
|
44
|
+
}
|
|
35
45
|
// Supabase returns 406 for some "not found" conditions (e.g. snippets)
|
|
36
46
|
const effectiveStatus = status === 406 ? 404 : status;
|
|
37
47
|
const ErrorClass = (HTTP_STATUS_MAP as any)[effectiveStatus];
|
package/src/errors.ts
CHANGED
|
@@ -37,6 +37,21 @@ export class UnknownSupabaseError extends Schema.TaggedErrorClass<UnknownSupabas
|
|
|
37
37
|
},
|
|
38
38
|
).pipe(Category.withServerError) {}
|
|
39
39
|
|
|
40
|
+
// Returned when v1CreateAProject is called against an org whose owner has
|
|
41
|
+
// already hit the free-tier active-project ceiling (currently 2). Supabase
|
|
42
|
+
// surfaces this as a generic 4xx with the literal message
|
|
43
|
+
// "The following organization members have reached their maximum limits
|
|
44
|
+
// for the number of active free projects within organizations where
|
|
45
|
+
// they are an administrator or owner: <email> (<n> project limit)..."
|
|
46
|
+
// We tag it explicitly so tests can detect it, clean up stale projects,
|
|
47
|
+
// and retry — and so callers can distinguish it from a real BadRequest.
|
|
48
|
+
export class FreeProjectLimitReached extends Schema.TaggedErrorClass<FreeProjectLimitReached>()(
|
|
49
|
+
"FreeProjectLimitReached",
|
|
50
|
+
{
|
|
51
|
+
message: Schema.String,
|
|
52
|
+
},
|
|
53
|
+
).pipe(Category.withQuotaError) {}
|
|
54
|
+
|
|
40
55
|
// Schema parse error wrapper
|
|
41
56
|
export class SupabaseParseError extends Schema.TaggedErrorClass<SupabaseParseError>()(
|
|
42
57
|
"SupabaseParseError",
|