diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9784faa..46b4d64 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -17,6 +17,10 @@ jobs: runs-on: ubuntu-latest + permissions: + contents: read + id-token: write + steps: - uses: actions/checkout@v4 diff --git a/.releaserc.json b/.releaserc.json index bc5246b..2aa1234 100644 --- a/.releaserc.json +++ b/.releaserc.json @@ -21,6 +21,7 @@ "@semantic-release/commit-analyzer", "@semantic-release/release-notes-generator", "@semantic-release/github", - "@semantic-release/npm" + "@semantic-release/npm", + "@sebbo2002/semantic-release-jsr" ] } diff --git a/jsr.json b/jsr.json new file mode 100644 index 0000000..4db21f3 --- /dev/null +++ b/jsr.json @@ -0,0 +1,8 @@ +{ + "name": "@supabase/functions-js", + "version": "0.0.0-automated", + "exports": { + ".": "./src/index.ts", + "./edge-runtime.d.ts": "./src/edge-runtime.d.ts" + } +} diff --git a/package-lock.json b/package-lock.json index 42e5cb0..bc07e69 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,6 +12,7 @@ "@supabase/node-fetch": "^2.6.14" }, "devDependencies": { + "@sebbo2002/semantic-release-jsr": "^1.0.0", "@types/jest": "^28.1.0", "@types/jsonwebtoken": "^8.5.8", "@types/node": "^18.7.0", @@ -1251,6 +1252,18 @@ "@octokit/openapi-types": "^13.11.0" } }, + "node_modules/@sebbo2002/semantic-release-jsr": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@sebbo2002/semantic-release-jsr/-/semantic-release-jsr-1.0.0.tgz", + "integrity": "sha512-R4CQqDfzvaaPXcwjUknmR/mrZkG3qhSG6zDqZ92XOWPoDdIfg6O4jmtTlQaxKVGGf62G4NaMhsAoEQtpSYjz0A==", + "dev": true, + "dependencies": { + "jsr": "^0.12.2" + }, + "engines": { + "node": ">=18.0.0" + } + }, "node_modules/@semantic-release/commit-analyzer": { "version": "9.0.2", "resolved": "https://registry.npmjs.org/@semantic-release/commit-analyzer/-/commit-analyzer-9.0.2.tgz", @@ -5084,6 +5097,20 @@ "node": ">=10" } }, + "node_modules/jsr": { + "version": "0.12.4", + "resolved": "https://registry.npmjs.org/jsr/-/jsr-0.12.4.tgz", + "integrity": "sha512-ZWDvqQE8014fWz9QBrkiuvRQ8mH97PRD13VIDzoMXDem3ff2S+wfXw+YAvrZE0aKzxh9FuHJX0HQRQ2MUHshig==", + "dev": true, + "dependencies": { + "kolorist": "^1.8.0", + "node-stream-zip": "^1.15.0", + "semiver": "^1.1.0" + }, + "bin": { + "jsr": "dist/bin.js" + } + }, "node_modules/jwa": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/jwa/-/jwa-1.4.1.tgz", @@ -5123,6 +5150,12 @@ "node": ">=6" } }, + "node_modules/kolorist": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/kolorist/-/kolorist-1.8.0.tgz", + "integrity": "sha512-Y+60/zizpJ3HRH8DCss+q95yr6145JXZo46OTpFvDZWLfRCE4qChOyk1b26nMaNpfHHgxagk9dXT5OP0Tfe+dQ==", + "dev": true + }, "node_modules/lazystream": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/lazystream/-/lazystream-1.0.1.tgz", @@ -5952,6 +5985,19 @@ "integrity": "sha512-PiVXnNuFm5+iYkLBNeq5211hvO38y63T0i2KKh2KnUs3RpzJ+JtODFjkD8yjLwnDkTYF1eKXheUwdssR+NRZdg==", "dev": true }, + "node_modules/node-stream-zip": { + "version": "1.15.0", + "resolved": "https://registry.npmjs.org/node-stream-zip/-/node-stream-zip-1.15.0.tgz", + "integrity": "sha512-LN4fydt9TqhZhThkZIVQnF9cwjU3qmUH9h78Mx/K7d3VvfRqqwthLwJEUOEL0QPZ0XQmNN7be5Ggit5+4dq3Bw==", + "dev": true, + "engines": { + "node": ">=0.12.0" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/antelle" + } + }, "node_modules/normalize-package-data": { "version": "2.5.0", "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.5.0.tgz", @@ -9754,6 +9800,15 @@ "node": ">=10" } }, + "node_modules/semiver": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/semiver/-/semiver-1.1.0.tgz", + "integrity": "sha512-QNI2ChmuioGC1/xjyYwyZYADILWyW6AmS1UH6gDj/SFUUUS4MBAWs/7mxnkRPc/F4iHezDP+O8t0dO8WHiEOdg==", + "dev": true, + "engines": { + "node": ">=6" + } + }, "node_modules/semver": { "version": "6.3.0", "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", @@ -12169,6 +12224,15 @@ "@octokit/openapi-types": "^13.11.0" } }, + "@sebbo2002/semantic-release-jsr": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@sebbo2002/semantic-release-jsr/-/semantic-release-jsr-1.0.0.tgz", + "integrity": "sha512-R4CQqDfzvaaPXcwjUknmR/mrZkG3qhSG6zDqZ92XOWPoDdIfg6O4jmtTlQaxKVGGf62G4NaMhsAoEQtpSYjz0A==", + "dev": true, + "requires": { + "jsr": "^0.12.2" + } + }, "@semantic-release/commit-analyzer": { "version": "9.0.2", "resolved": "https://registry.npmjs.org/@semantic-release/commit-analyzer/-/commit-analyzer-9.0.2.tgz", @@ -15082,6 +15146,17 @@ } } }, + "jsr": { + "version": "0.12.4", + "resolved": "https://registry.npmjs.org/jsr/-/jsr-0.12.4.tgz", + "integrity": "sha512-ZWDvqQE8014fWz9QBrkiuvRQ8mH97PRD13VIDzoMXDem3ff2S+wfXw+YAvrZE0aKzxh9FuHJX0HQRQ2MUHshig==", + "dev": true, + "requires": { + "kolorist": "^1.8.0", + "node-stream-zip": "^1.15.0", + "semiver": "^1.1.0" + } + }, "jwa": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/jwa/-/jwa-1.4.1.tgz", @@ -15115,6 +15190,12 @@ "integrity": "sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w==", "dev": true }, + "kolorist": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/kolorist/-/kolorist-1.8.0.tgz", + "integrity": "sha512-Y+60/zizpJ3HRH8DCss+q95yr6145JXZo46OTpFvDZWLfRCE4qChOyk1b26nMaNpfHHgxagk9dXT5OP0Tfe+dQ==", + "dev": true + }, "lazystream": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/lazystream/-/lazystream-1.0.1.tgz", @@ -15748,6 +15829,12 @@ "integrity": "sha512-PiVXnNuFm5+iYkLBNeq5211hvO38y63T0i2KKh2KnUs3RpzJ+JtODFjkD8yjLwnDkTYF1eKXheUwdssR+NRZdg==", "dev": true }, + "node-stream-zip": { + "version": "1.15.0", + "resolved": "https://registry.npmjs.org/node-stream-zip/-/node-stream-zip-1.15.0.tgz", + "integrity": "sha512-LN4fydt9TqhZhThkZIVQnF9cwjU3qmUH9h78Mx/K7d3VvfRqqwthLwJEUOEL0QPZ0XQmNN7be5Ggit5+4dq3Bw==", + "dev": true + }, "normalize-package-data": { "version": "2.5.0", "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.5.0.tgz", @@ -18446,6 +18533,12 @@ "glob": "^7.1.3" } }, + "semiver": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/semiver/-/semiver-1.1.0.tgz", + "integrity": "sha512-QNI2ChmuioGC1/xjyYwyZYADILWyW6AmS1UH6gDj/SFUUUS4MBAWs/7mxnkRPc/F4iHezDP+O8t0dO8WHiEOdg==", + "dev": true + }, "semver": { "version": "6.3.0", "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", diff --git a/package.json b/package.json index 2aad108..4084718 100644 --- a/package.json +++ b/package.json @@ -39,6 +39,7 @@ "@supabase/node-fetch": "^2.6.14" }, "devDependencies": { + "@sebbo2002/semantic-release-jsr": "^1.0.0", "@types/jest": "^28.1.0", "@types/jsonwebtoken": "^8.5.8", "@types/node": "^18.7.0", diff --git a/src/index.ts b/src/index.ts index 1ad5c1d..dfb4b78 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,10 +1,10 @@ export { FunctionsClient } from './FunctionsClient' export { - FunctionInvokeOptions, + type FunctionInvokeOptions, FunctionsError, FunctionsFetchError, FunctionsHttpError, FunctionsRelayError, FunctionRegion, - FunctionsResponse + type FunctionsResponse, } from './types' diff --git a/src/types.ts b/src/types.ts index 3fca51c..93eb496 100644 --- a/src/types.ts +++ b/src/types.ts @@ -71,7 +71,7 @@ export type FunctionInvokeOptions = { /** * The Region to invoke the function in. */ - region?: FunctionRegion; + region?: FunctionRegion /** * The body of the request. */ diff --git a/test/spec/params.spec.ts b/test/spec/params.spec.ts index 63c1786..1383d48 100644 --- a/test/spec/params.spec.ts +++ b/test/spec/params.spec.ts @@ -248,7 +248,7 @@ describe('params reached to function', () => { 'custom-header': customHeader, Authorization: `Bearer ${apiKey}`, }, - region: FunctionRegion.Any + region: FunctionRegion.Any, }) log('assert no error') @@ -278,23 +278,25 @@ describe('params reached to function', () => { * @feature headers */ log('create FunctionsClient') - const fclient = new FunctionsClient(`http://localhost:${relay.container.getMappedPort(8081)}`,{region: FunctionRegion.ApNortheast1}) + const fclient = new FunctionsClient(`http://localhost:${relay.container.getMappedPort(8081)}`, { + region: FunctionRegion.ApNortheast1, + }) log('invoke mirror') const customHeader = nanoid() - const { data, error } = await fclient.invoke('mirror', { headers: { 'custom-header': customHeader, - Authorization: `Bearer ${apiKey}` + Authorization: `Bearer ${apiKey}`, }, }) log('assert no error') expect( - (data?.headers as [Array]).filter(([k, v]) => k === 'x-region' && v === FunctionRegion.ApNortheast1) - .length > 0 + (data?.headers as [Array]).filter( + ([k, v]) => k === 'x-region' && v === FunctionRegion.ApNortheast1 + ).length > 0 ).toBe(true) }) diff --git a/tsconfig.json b/tsconfig.json index f96f27f..29ea071 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -14,6 +14,7 @@ "esModuleInterop": true, "moduleResolution": "Node", + "isolatedModules": true, "forceConsistentCasingInFileNames": true, "stripInternal": true,