@hot-updater/supabase 1.2.0-rc.50 → 1.2.0-rc.52
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/edge.cjs +1 -1
- package/dist/edge.mjs +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/init/index.cjs +1 -0
- package/dist/init/index.mjs +2 -1
- package/dist/{supabaseStorage-B6IM8UX2.mjs → supabaseStorage-BoMZ6ay3.mjs} +33 -2
- package/dist/{supabaseStorage-DUa49vGh.cjs → supabaseStorage-CkMp_r4q.cjs} +33 -2
- package/package.json +8 -8
- package/supabase/migrations/0002_hot-updater_1.2.0.sql +9 -1
package/dist/edge.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_supabaseStorage = require("./supabaseStorage-
|
|
2
|
+
const require_supabaseStorage = require("./supabaseStorage-CkMp_r4q.cjs");
|
|
3
3
|
exports.supabaseDatabase = require_supabaseStorage.supabaseDatabase;
|
|
4
4
|
exports.supabaseStorage = require_supabaseStorage.supabaseStorage;
|
package/dist/edge.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as supabaseDatabase, t as supabaseStorage } from "./supabaseStorage-
|
|
1
|
+
import { n as supabaseDatabase, t as supabaseStorage } from "./supabaseStorage-BoMZ6ay3.mjs";
|
|
2
2
|
export { supabaseDatabase, supabaseStorage };
|
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_supabaseStorage = require("./supabaseStorage-
|
|
2
|
+
const require_supabaseStorage = require("./supabaseStorage-CkMp_r4q.cjs");
|
|
3
3
|
let _hot_updater_plugin_core = require("@hot-updater/plugin-core");
|
|
4
4
|
//#region src/supabaseSchema.ts
|
|
5
5
|
/** Every table the apply RPC may name: models, index tables, settings, and the write guard. */
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as SUPABASE_TABLE_PREFIX, n as supabaseDatabase$1, r as SUPABASE_APPLY_FUNCTION, t as supabaseStorage } from "./supabaseStorage-
|
|
1
|
+
import { i as SUPABASE_TABLE_PREFIX, n as supabaseDatabase$1, r as SUPABASE_APPLY_FUNCTION, t as supabaseStorage } from "./supabaseStorage-BoMZ6ay3.mjs";
|
|
2
2
|
import { SETTINGS_TABLE, WRITE_GUARD_TABLE, coreSettings, coreTarget, createTableStatements, generateEngineSql, isMultiIndex } from "@hot-updater/plugin-core";
|
|
3
3
|
//#region src/supabaseSchema.ts
|
|
4
4
|
/** Every table the apply RPC may name: models, index tables, settings, and the write guard. */
|
package/dist/init/index.cjs
CHANGED
|
@@ -7707,6 +7707,7 @@ const runInitWithoutCliMetadata = async ({ build, envFile, secretsEnv }) => {
|
|
|
7707
7707
|
});
|
|
7708
7708
|
({clientPlugins} = managedServer);
|
|
7709
7709
|
try {
|
|
7710
|
+
await (0, _hot_updater_cli_tools.fillReleaseLabels)(managedServer);
|
|
7710
7711
|
credential = await (0, _hot_updater_cli_tools.provisionClientCredential)(managedServer, {
|
|
7711
7712
|
env: initInputEnv,
|
|
7712
7713
|
name: "Supabase init"
|
package/dist/init/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createRequire } from "node:module";
|
|
2
2
|
import fs from "fs/promises";
|
|
3
3
|
import path from "path";
|
|
4
|
-
import { ConfigBuilder, InitError, MissingInitInputsError, assembleServer, assertInfrastructureGenerationAtUrl, assertInitInputs, assertInitProviderInputs, confirmInitInputPersistence, copyDirToTmp, createHotUpdaterConfigScaffoldFromBuilder, getHotUpdaterEnvValue, getHotUpdaterInitInputEnv, getInitProviderEnvVars, getInitProviderTextPromptValues, link, makeEnv, moduleSpecifiersOf, p, printAppSetup, provisionClientCredential, readHotUpdaterInitEnv, resolveInitProviderInput, resolvePackageVersion, transformEnv, transformTemplate, writeHotUpdaterFiles } from "@hot-updater/cli-tools";
|
|
4
|
+
import { ConfigBuilder, InitError, MissingInitInputsError, assembleServer, assertInfrastructureGenerationAtUrl, assertInitInputs, assertInitProviderInputs, confirmInitInputPersistence, copyDirToTmp, createHotUpdaterConfigScaffoldFromBuilder, fillReleaseLabels, getHotUpdaterEnvValue, getHotUpdaterInitInputEnv, getInitProviderEnvVars, getInitProviderTextPromptValues, link, makeEnv, moduleSpecifiersOf, p, printAppSetup, provisionClientCredential, readHotUpdaterInitEnv, resolveInitProviderInput, resolvePackageVersion, transformEnv, transformTemplate, writeHotUpdaterFiles } from "@hot-updater/cli-tools";
|
|
5
5
|
import { apiKeys, insights, remoteConfig } from "@hot-updater/server/plugins";
|
|
6
6
|
import { fileURLToPath } from "node:url";
|
|
7
7
|
import { ChildProcess, execFile, spawn, spawnSync } from "node:child_process";
|
|
@@ -7702,6 +7702,7 @@ const runInitWithoutCliMetadata = async ({ build, envFile, secretsEnv }) => {
|
|
|
7702
7702
|
});
|
|
7703
7703
|
({clientPlugins} = managedServer);
|
|
7704
7704
|
try {
|
|
7705
|
+
await fillReleaseLabels(managedServer);
|
|
7705
7706
|
credential = await provisionClientCredential(managedServer, {
|
|
7706
7707
|
env: initInputEnv,
|
|
7707
7708
|
name: "Supabase init"
|
|
@@ -164,6 +164,32 @@ const isMissingObjectError = async (error) => {
|
|
|
164
164
|
const body = await response.json().catch(() => void 0);
|
|
165
165
|
return typeof body === "object" && body !== null && Reflect.get(body, "error") === "not_found";
|
|
166
166
|
};
|
|
167
|
+
/** The one-line description of a request Storage failed with `status`. */
|
|
168
|
+
const answeredHttp = (status) => `Supabase Storage answered HTTP ${status}`;
|
|
169
|
+
/**
|
|
170
|
+
* fetch for supabase-js, which reads the body of a failed request as JSON. A
|
|
171
|
+
* gateway in front of Storage answers some failures, such as a 502, with an
|
|
172
|
+
* HTML page, which would fail as a JSON parse error without its status. Such
|
|
173
|
+
* a response becomes a JSON error that names the status. A HEAD response
|
|
174
|
+
* has no body, and supabase-js reads it unparsed.
|
|
175
|
+
*/
|
|
176
|
+
const storageFetch = async (input, init) => {
|
|
177
|
+
const response = await fetch(input, init);
|
|
178
|
+
if (response.ok || init?.method === "HEAD") return response;
|
|
179
|
+
try {
|
|
180
|
+
JSON.parse(await response.clone().text());
|
|
181
|
+
return response;
|
|
182
|
+
} catch {
|
|
183
|
+
return Response.json({
|
|
184
|
+
statusCode: String(response.status),
|
|
185
|
+
error: response.statusText,
|
|
186
|
+
message: answeredHttp(response.status)
|
|
187
|
+
}, {
|
|
188
|
+
status: response.status,
|
|
189
|
+
statusText: response.statusText
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
};
|
|
167
193
|
/** A character Storage rejects in an object name, `?`, or `!`. */
|
|
168
194
|
const ESCAPED_CHARACTER = /[^A-Za-z0-9_/.*'() &$=@;:+,-]/gu;
|
|
169
195
|
const ESCAPE_SEQUENCE = /!([0-9A-F]{2})/gu;
|
|
@@ -215,7 +241,7 @@ const fromObjectName = (name) => {
|
|
|
215
241
|
};
|
|
216
242
|
const supabaseStorage = (config) => {
|
|
217
243
|
let client;
|
|
218
|
-
const bucket = async () => (await (client ??= resolveSupabaseServiceRoleKey(config).then((key) => createClient(config.supabaseUrl, key), (error) => {
|
|
244
|
+
const bucket = async () => (await (client ??= resolveSupabaseServiceRoleKey(config).then((key) => createClient(config.supabaseUrl, key, { global: { fetch: storageFetch } }), (error) => {
|
|
219
245
|
client = void 0;
|
|
220
246
|
throw error;
|
|
221
247
|
}))).storage.from(config.bucketName);
|
|
@@ -243,7 +269,12 @@ const supabaseStorage = (config) => {
|
|
|
243
269
|
duplex: "half",
|
|
244
270
|
...contentLength === void 0 ? {} : { headers: { "content-length": String(contentLength) } }
|
|
245
271
|
});
|
|
246
|
-
if (error)
|
|
272
|
+
if (error) {
|
|
273
|
+
const status = Reflect.get(error, "status");
|
|
274
|
+
if (typeof status !== "number") throw error;
|
|
275
|
+
const detail = error.message === answeredHttp(status) ? "" : `: ${error.message}`;
|
|
276
|
+
throw new Error(`${answeredHttp(status)} while uploading ${storageKey}${detail}`, { cause: error });
|
|
277
|
+
}
|
|
247
278
|
return { storageUri: createStorageUri({
|
|
248
279
|
protocol: "supabase-storage",
|
|
249
280
|
bucket: config.bucketName,
|
|
@@ -164,6 +164,32 @@ const isMissingObjectError = async (error) => {
|
|
|
164
164
|
const body = await response.json().catch(() => void 0);
|
|
165
165
|
return typeof body === "object" && body !== null && Reflect.get(body, "error") === "not_found";
|
|
166
166
|
};
|
|
167
|
+
/** The one-line description of a request Storage failed with `status`. */
|
|
168
|
+
const answeredHttp = (status) => `Supabase Storage answered HTTP ${status}`;
|
|
169
|
+
/**
|
|
170
|
+
* fetch for supabase-js, which reads the body of a failed request as JSON. A
|
|
171
|
+
* gateway in front of Storage answers some failures, such as a 502, with an
|
|
172
|
+
* HTML page, which would fail as a JSON parse error without its status. Such
|
|
173
|
+
* a response becomes a JSON error that names the status. A HEAD response
|
|
174
|
+
* has no body, and supabase-js reads it unparsed.
|
|
175
|
+
*/
|
|
176
|
+
const storageFetch = async (input, init) => {
|
|
177
|
+
const response = await fetch(input, init);
|
|
178
|
+
if (response.ok || init?.method === "HEAD") return response;
|
|
179
|
+
try {
|
|
180
|
+
JSON.parse(await response.clone().text());
|
|
181
|
+
return response;
|
|
182
|
+
} catch {
|
|
183
|
+
return Response.json({
|
|
184
|
+
statusCode: String(response.status),
|
|
185
|
+
error: response.statusText,
|
|
186
|
+
message: answeredHttp(response.status)
|
|
187
|
+
}, {
|
|
188
|
+
status: response.status,
|
|
189
|
+
statusText: response.statusText
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
};
|
|
167
193
|
/** A character Storage rejects in an object name, `?`, or `!`. */
|
|
168
194
|
const ESCAPED_CHARACTER = /[^A-Za-z0-9_/.*'() &$=@;:+,-]/gu;
|
|
169
195
|
const ESCAPE_SEQUENCE = /!([0-9A-F]{2})/gu;
|
|
@@ -215,7 +241,7 @@ const fromObjectName = (name) => {
|
|
|
215
241
|
};
|
|
216
242
|
const supabaseStorage = (config) => {
|
|
217
243
|
let client;
|
|
218
|
-
const bucket = async () => (await (client ??= resolveSupabaseServiceRoleKey(config).then((key) => (0, _supabase_supabase_js.createClient)(config.supabaseUrl, key), (error) => {
|
|
244
|
+
const bucket = async () => (await (client ??= resolveSupabaseServiceRoleKey(config).then((key) => (0, _supabase_supabase_js.createClient)(config.supabaseUrl, key, { global: { fetch: storageFetch } }), (error) => {
|
|
219
245
|
client = void 0;
|
|
220
246
|
throw error;
|
|
221
247
|
}))).storage.from(config.bucketName);
|
|
@@ -243,7 +269,12 @@ const supabaseStorage = (config) => {
|
|
|
243
269
|
duplex: "half",
|
|
244
270
|
...contentLength === void 0 ? {} : { headers: { "content-length": String(contentLength) } }
|
|
245
271
|
});
|
|
246
|
-
if (error)
|
|
272
|
+
if (error) {
|
|
273
|
+
const status = Reflect.get(error, "status");
|
|
274
|
+
if (typeof status !== "number") throw error;
|
|
275
|
+
const detail = error.message === answeredHttp(status) ? "" : `: ${error.message}`;
|
|
276
|
+
throw new Error(`${answeredHttp(status)} while uploading ${storageKey}${detail}`, { cause: error });
|
|
277
|
+
}
|
|
247
278
|
return { storageUri: (0, _hot_updater_plugin_core.createStorageUri)({
|
|
248
279
|
protocol: "supabase-storage",
|
|
249
280
|
bucket: config.bucketName,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hot-updater/supabase",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.2.0-rc.
|
|
4
|
+
"version": "1.2.0-rc.52",
|
|
5
5
|
"description": "React Native OTA solution for self-hosted",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
7
7
|
"module": "dist/index.mjs",
|
|
@@ -51,10 +51,10 @@
|
|
|
51
51
|
"@supabase/supabase-js": "2.76.1",
|
|
52
52
|
"hono": "4.12.34",
|
|
53
53
|
"uuidv7": "^1.0.2",
|
|
54
|
-
"@hot-updater/protocol": "1.2.0-rc.
|
|
55
|
-
"@hot-updater/plugin-core": "1.2.0-rc.
|
|
56
|
-
"@hot-updater/
|
|
57
|
-
"@hot-updater/
|
|
54
|
+
"@hot-updater/protocol": "1.2.0-rc.52",
|
|
55
|
+
"@hot-updater/plugin-core": "1.2.0-rc.52",
|
|
56
|
+
"@hot-updater/cli-tools": "1.2.0-rc.52",
|
|
57
|
+
"@hot-updater/server": "1.2.0-rc.52"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
60
|
"@electric-sql/pglite": "0.4.1",
|
|
@@ -64,9 +64,9 @@
|
|
|
64
64
|
"execa": "9.5.2",
|
|
65
65
|
"@types/node": "^20",
|
|
66
66
|
"mime": "^4.0.4",
|
|
67
|
-
"@hot-updater/mock": "1.2.0-rc.
|
|
68
|
-
"@hot-updater/test-utils": "1.2.0-rc.
|
|
69
|
-
"@hot-updater/postgres": "1.2.0-rc.
|
|
67
|
+
"@hot-updater/mock": "1.2.0-rc.52",
|
|
68
|
+
"@hot-updater/test-utils": "1.2.0-rc.52",
|
|
69
|
+
"@hot-updater/postgres": "1.2.0-rc.52"
|
|
70
70
|
},
|
|
71
71
|
"scripts": {
|
|
72
72
|
"build": "tsdown",
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
-- HotUpdater.schema
|
|
2
2
|
|
|
3
|
+
ALTER TABLE "hot_updater_v1_releases" ADD COLUMN IF NOT EXISTS "label" bigint;
|
|
4
|
+
|
|
5
|
+
CREATE UNIQUE INDEX IF NOT EXISTS "hot_updater_v1_releases_byLabel" ON "hot_updater_v1_releases" ("channel_id", "platform", "label");
|
|
6
|
+
|
|
3
7
|
CREATE TABLE IF NOT EXISTS "hot_updater_v1_native_builds" ("id" varchar(36) COLLATE "C" NOT NULL, "scope_key" varchar(2048) COLLATE "C" NOT NULL, "platform" varchar(16) COLLATE "C" NOT NULL, "channel_id" varchar(1408) COLLATE "C" NOT NULL, "fingerprint_hash" varchar(255) COLLATE "C", "app_version" text COLLATE "C", "min_bundle_id" varchar(36) COLLATE "C" NOT NULL, "artifact_kind" varchar(16) COLLATE "C" NOT NULL, "artifact_storage_uri" text COLLATE "C" NOT NULL, "byte_size" bigint NOT NULL, "git_commit_hash" varchar(255) COLLATE "C", "created_at_ms" bigint NOT NULL, "build_key" varchar(69) COLLATE "C", "build_number" varchar(64) COLLATE "C", "submitted_to" varchar(16) COLLATE "C", "submitted_at_ms" bigint, "submitted_version" varchar(255) COLLATE "C", "is_store_build" boolean NOT NULL, "is_sandbox" boolean NOT NULL, "sandbox_url_scheme" varchar(255) COLLATE "C", "export_method" varchar(16) COLLATE "C", "native_app_version" text COLLATE "C", "store_build_scope_key" varchar(2048) COLLATE "C", "_v" bigint NOT NULL DEFAULT 0, PRIMARY KEY ("id"));
|
|
4
8
|
|
|
5
9
|
CREATE INDEX IF NOT EXISTS "hot_updater_v1_native_builds_byScope" ON "hot_updater_v1_native_builds" ("scope_key", "id");
|
|
@@ -24,6 +28,8 @@ CREATE UNIQUE INDEX IF NOT EXISTS "hot_updater_v1_ios_devices_udid" ON "hot_upda
|
|
|
24
28
|
|
|
25
29
|
CREATE TABLE IF NOT EXISTS "hot_updater_v1_ios_device_account" ("id" varchar(16) COLLATE "C" NOT NULL, "apple_issuer_id" varchar(64) COLLATE "C" NOT NULL, "claimed_at_ms" bigint NOT NULL, "_v" bigint NOT NULL DEFAULT 0, PRIMARY KEY ("id"));
|
|
26
30
|
|
|
31
|
+
CREATE TABLE IF NOT EXISTS "hot_updater_v1_label_sequences" ("id" varchar(1440) COLLATE "C" NOT NULL, "last_label" bigint NOT NULL, "is_filled" boolean NOT NULL, "_v" bigint NOT NULL DEFAULT 0, PRIMARY KEY ("id"));
|
|
32
|
+
|
|
27
33
|
CREATE INDEX IF NOT EXISTS "hot_updater_v1_bundle_events__byBundle__key" ON "hot_updater_v1_bundle_events__byBundle" ("id");
|
|
28
34
|
|
|
29
35
|
ALTER TABLE "hot_updater_v1_native_builds" ENABLE ROW LEVEL SECURITY;
|
|
@@ -32,6 +38,8 @@ ALTER TABLE "hot_updater_v1_ios_devices" ENABLE ROW LEVEL SECURITY;
|
|
|
32
38
|
|
|
33
39
|
ALTER TABLE "hot_updater_v1_ios_device_account" ENABLE ROW LEVEL SECURITY;
|
|
34
40
|
|
|
41
|
+
ALTER TABLE "hot_updater_v1_label_sequences" ENABLE ROW LEVEL SECURITY;
|
|
42
|
+
|
|
35
43
|
CREATE OR REPLACE FUNCTION public.hot_updater_v1_apply(p_statements jsonb)
|
|
36
44
|
RETURNS jsonb
|
|
37
45
|
LANGUAGE plpgsql
|
|
@@ -51,7 +59,7 @@ BEGIN
|
|
|
51
59
|
FOR item IN SELECT value FROM jsonb_array_elements(p_statements) LOOP
|
|
52
60
|
statement := item->>'sql';
|
|
53
61
|
FOR target IN SELECT (regexp_matches(statement, '(?:FROM|INTO|UPDATE|JOIN) "([^"]+)"', 'g'))[1] LOOP
|
|
54
|
-
IF NOT target = ANY (ARRAY['hot_updater_v1_bundles', 'hot_updater_v1_bundle_patches', 'hot_updater_v1_releases', 'hot_updater_v1_release_catalogs', 'hot_updater_v1_channels', 'hot_updater_v1_bundle_totals', 'hot_updater_v1_native_builds', 'hot_updater_v1_ios_devices', 'hot_updater_v1_ios_device_account', 'hot_updater_v1_bundle_events', 'hot_updater_v1_bundle_events__byBundle', 'hot_updater_v1_bundle_event_heads', 'hot_updater_v1_insights_overview', 'hot_updater_v1_insights_sketches', 'hot_updater_v1_insights_overview_daily', 'hot_updater_v1_insights_sketches_daily', 'hot_updater_v1_insights_overview_lifetime', 'hot_updater_v1_insights_sketches_lifetime', 'hot_updater_v1_insights_distribution', 'hot_updater_v1_insights_builtin_distribution', 'hot_updater_v1_insights_latest_by_bundle', 'hot_updater_v1_insights_outcomes', 'hot_updater_v1_insights_failures', 'hot_updater_v1_api_keys', 'hot_updater_v1_remote_config_active', 'hot_updater_v1_remote_config_versions', 'hot_updater_v1_private_hot_updater_settings', 'hot_updater_v1__hu_write']) THEN
|
|
62
|
+
IF NOT target = ANY (ARRAY['hot_updater_v1_bundles', 'hot_updater_v1_bundle_patches', 'hot_updater_v1_releases', 'hot_updater_v1_release_catalogs', 'hot_updater_v1_channels', 'hot_updater_v1_bundle_totals', 'hot_updater_v1_native_builds', 'hot_updater_v1_ios_devices', 'hot_updater_v1_ios_device_account', 'hot_updater_v1_label_sequences', 'hot_updater_v1_bundle_events', 'hot_updater_v1_bundle_events__byBundle', 'hot_updater_v1_bundle_event_heads', 'hot_updater_v1_insights_overview', 'hot_updater_v1_insights_sketches', 'hot_updater_v1_insights_overview_daily', 'hot_updater_v1_insights_sketches_daily', 'hot_updater_v1_insights_overview_lifetime', 'hot_updater_v1_insights_sketches_lifetime', 'hot_updater_v1_insights_distribution', 'hot_updater_v1_insights_builtin_distribution', 'hot_updater_v1_insights_latest_by_bundle', 'hot_updater_v1_insights_outcomes', 'hot_updater_v1_insights_failures', 'hot_updater_v1_api_keys', 'hot_updater_v1_remote_config_active', 'hot_updater_v1_remote_config_versions', 'hot_updater_v1_private_hot_updater_settings', 'hot_updater_v1__hu_write']) THEN
|
|
55
63
|
RAISE EXCEPTION 'hot_updater_v1_apply: % is not a Hot Updater table', target USING ERRCODE = '42501';
|
|
56
64
|
END IF;
|
|
57
65
|
END LOOP;
|