@alienplatform/bindings 1.0.0 → 2.0.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.
- package/LICENSE.md +105 -0
- package/README.md +59 -0
- package/dist/errors.d.ts +56 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/factories.d.ts +26 -0
- package/dist/factories.d.ts.map +1 -0
- package/dist/index.d.ts +19 -1768
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +23 -44772
- package/dist/loader.d.ts +171 -0
- package/dist/loader.d.ts.map +1 -0
- package/dist/loader.js +3712 -0
- package/dist/native.d.ts +41 -0
- package/dist/native.d.ts.map +1 -0
- package/dist/native.js +46 -0
- package/dist/types.d.ts +150 -0
- package/dist/types.d.ts.map +1 -0
- package/package.json +39 -21
- package/AGENTS.md +0 -70
- package/dist/index.js.map +0 -1
- package/scripts/generate-proto.sh +0 -46
- package/src/bindings/AGENTS.md +0 -105
- package/src/bindings/artifact-registry.ts +0 -314
- package/src/bindings/build.ts +0 -195
- package/src/bindings/function.ts +0 -164
- package/src/bindings/index.ts +0 -12
- package/src/bindings/kv.ts +0 -240
- package/src/bindings/queue.ts +0 -191
- package/src/bindings/service-account.ts +0 -113
- package/src/bindings/storage.ts +0 -535
- package/src/bindings/vault.ts +0 -133
- package/src/channel.ts +0 -94
- package/src/commands.ts +0 -76
- package/src/context.ts +0 -368
- package/src/errors.ts +0 -259
- package/src/events.ts +0 -463
- package/src/generated/artifact_registry.ts +0 -1934
- package/src/generated/build.ts +0 -1263
- package/src/generated/container.ts +0 -485
- package/src/generated/control.ts +0 -1574
- package/src/generated/function.ts +0 -741
- package/src/generated/google/protobuf/duration.ts +0 -196
- package/src/generated/google/protobuf/timestamp.ts +0 -225
- package/src/generated/kv.ts +0 -1137
- package/src/generated/queue.ts +0 -729
- package/src/generated/service_account.ts +0 -766
- package/src/generated/storage.ts +0 -3653
- package/src/generated/vault.ts +0 -519
- package/src/generated/wait_until.ts +0 -781
- package/src/global.ts +0 -316
- package/src/grpc-utils.ts +0 -159
- package/src/index.ts +0 -156
- package/src/types.ts +0 -384
- package/src/wait-until.ts +0 -257
- package/tsconfig.json +0 -8
- package/tsdown.config.ts +0 -14
package/LICENSE.md
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
# Functional Source License, Version 1.1, Apache 2.0 Future License
|
|
2
|
+
|
|
3
|
+
## Abbreviation
|
|
4
|
+
|
|
5
|
+
FSL-1.1-Apache-2.0
|
|
6
|
+
|
|
7
|
+
## Notice
|
|
8
|
+
|
|
9
|
+
Copyright 2026 Alien Software, Inc.
|
|
10
|
+
|
|
11
|
+
## Terms and Conditions
|
|
12
|
+
|
|
13
|
+
### Licensor ("We")
|
|
14
|
+
|
|
15
|
+
The party offering the Software under these Terms and Conditions.
|
|
16
|
+
|
|
17
|
+
### The Software
|
|
18
|
+
|
|
19
|
+
The "Software" is each version of the software that we make available under
|
|
20
|
+
these Terms and Conditions, as indicated by our inclusion of these Terms and
|
|
21
|
+
Conditions with the Software.
|
|
22
|
+
|
|
23
|
+
### License Grant
|
|
24
|
+
|
|
25
|
+
Subject to your compliance with this License Grant and the Patents,
|
|
26
|
+
Redistribution and Trademark clauses below, we hereby grant you the right to
|
|
27
|
+
use, copy, modify, create derivative works, publicly perform, publicly display
|
|
28
|
+
and redistribute the Software for any Permitted Purpose identified below.
|
|
29
|
+
|
|
30
|
+
### Permitted Purpose
|
|
31
|
+
|
|
32
|
+
A Permitted Purpose is any purpose other than a Competing Use. A Competing Use
|
|
33
|
+
means making the Software available to others in a commercial product or
|
|
34
|
+
service that:
|
|
35
|
+
|
|
36
|
+
1. substitutes for the Software;
|
|
37
|
+
|
|
38
|
+
2. substitutes for any other product or service we offer using the Software
|
|
39
|
+
that exists as of the date we make the Software available; or
|
|
40
|
+
|
|
41
|
+
3. offers the same or substantially similar functionality as the Software.
|
|
42
|
+
|
|
43
|
+
Permitted Purposes specifically include using the Software:
|
|
44
|
+
|
|
45
|
+
1. for your internal use and access;
|
|
46
|
+
|
|
47
|
+
2. for non-commercial education;
|
|
48
|
+
|
|
49
|
+
3. for non-commercial research; and
|
|
50
|
+
|
|
51
|
+
4. in connection with professional services that you provide to a licensee
|
|
52
|
+
using the Software in accordance with these Terms and Conditions.
|
|
53
|
+
|
|
54
|
+
### Patents
|
|
55
|
+
|
|
56
|
+
To the extent your use for a Permitted Purpose would necessarily infringe our
|
|
57
|
+
patents, the license grant above includes a license under our patents. If you
|
|
58
|
+
make a claim against any party that the Software infringes or contributes to
|
|
59
|
+
the infringement of any patent, then your patent license to the Software ends
|
|
60
|
+
immediately.
|
|
61
|
+
|
|
62
|
+
### Redistribution
|
|
63
|
+
|
|
64
|
+
The Terms and Conditions apply to all copies, modifications and derivatives of
|
|
65
|
+
the Software.
|
|
66
|
+
|
|
67
|
+
If you redistribute any copies, modifications or derivatives of the Software,
|
|
68
|
+
you must include a copy of or a link to these Terms and Conditions and not
|
|
69
|
+
remove any copyright notices provided in or with the Software.
|
|
70
|
+
|
|
71
|
+
### Disclaimer
|
|
72
|
+
|
|
73
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTIES OF ANY KIND, EXPRESS OR
|
|
74
|
+
IMPLIED, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR
|
|
75
|
+
PURPOSE, MERCHANTABILITY, TITLE OR NON-INFRINGEMENT.
|
|
76
|
+
|
|
77
|
+
IN NO EVENT WILL WE HAVE ANY LIABILITY TO YOU ARISING OUT OF OR RELATED TO THE
|
|
78
|
+
SOFTWARE, INCLUDING INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES,
|
|
79
|
+
EVEN IF WE HAVE BEEN INFORMED OF THEIR POSSIBILITY IN ADVANCE.
|
|
80
|
+
|
|
81
|
+
### Trademarks
|
|
82
|
+
|
|
83
|
+
Except for displaying the License Details and identifying us as the origin of
|
|
84
|
+
the Software, you have no right under these Terms and Conditions to use our
|
|
85
|
+
trademarks, trade names, service marks or product names.
|
|
86
|
+
|
|
87
|
+
## Grant of Future License
|
|
88
|
+
|
|
89
|
+
We hereby irrevocably grant you an additional license to use the Software under
|
|
90
|
+
the Apache License, Version 2.0 that is effective on the second anniversary of
|
|
91
|
+
the date we make the Software available. On or after that date, you may use the
|
|
92
|
+
Software under the Apache License, Version 2.0, in which case the following
|
|
93
|
+
will apply:
|
|
94
|
+
|
|
95
|
+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
96
|
+
this file except in compliance with the License.
|
|
97
|
+
|
|
98
|
+
You may obtain a copy of the License at
|
|
99
|
+
|
|
100
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
101
|
+
|
|
102
|
+
Unless required by applicable law or agreed to in writing, software distributed
|
|
103
|
+
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
|
104
|
+
CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
|
105
|
+
specific language governing permissions and limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# `@alienplatform/bindings`
|
|
2
|
+
|
|
3
|
+
Direct TypeScript bindings for Alien storage, kv, queue, and vault over an
|
|
4
|
+
in-process [napi-rs](https://napi.rs) addon. The addon itself lives in the Rust
|
|
5
|
+
crate `crates/alien-bindings-node`; this package is the published JavaScript
|
|
6
|
+
wrapper that loads it.
|
|
7
|
+
|
|
8
|
+
## Native addon resolution
|
|
9
|
+
|
|
10
|
+
The addon is loaded lazily on the first binding operation (never at import — the
|
|
11
|
+
package is `sideEffects: false`). `src/loader.ts` resolves it in order:
|
|
12
|
+
|
|
13
|
+
1. `ALIEN_BINDINGS_ADDON_PATH` — an explicit path to a `.node` file. A dev/test
|
|
14
|
+
escape hatch only; never set in a published install.
|
|
15
|
+
2. The per-platform prebuild package `@alienplatform/bindings-<triple>`, pulled
|
|
16
|
+
in as an `optionalDependency`. This is how end users get the addon: `npm`/`bun`
|
|
17
|
+
installs only the package matching the host `os`/`cpu`/`libc`. The
|
|
18
|
+
`optionalDependencies` block exists **only in the published manifest** — it is
|
|
19
|
+
injected at publish time by the release pipeline, so a workspace checkout
|
|
20
|
+
carries none.
|
|
21
|
+
3. Dev fallback: a locally-built addon at
|
|
22
|
+
`crates/alien-bindings-node/alien-bindings-node.<triple>.node`, found by
|
|
23
|
+
walking up from the installed package. Loaded only if its `version()` matches
|
|
24
|
+
this package's version (a stale build is warned about and rejected).
|
|
25
|
+
|
|
26
|
+
## Local development
|
|
27
|
+
|
|
28
|
+
Build the addon for your host once, then run anything that imports the package:
|
|
29
|
+
|
|
30
|
+
```sh
|
|
31
|
+
bun run build:addon # or: pnpm -C packages/bindings run build:addon
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
`build:addon` runs `napi build --platform --release` against
|
|
35
|
+
`crates/alien-bindings-node` and drops the `.node` next to the crate, where the
|
|
36
|
+
loader's dev fallback (step 3 above) finds it. Rebuild after changing any Rust
|
|
37
|
+
in `alien-bindings` or `alien-bindings-node`. The built `.node` is gitignored.
|
|
38
|
+
`build:addon` only builds for the host triple; on a Mac, cross-building the
|
|
39
|
+
other mac triple (e.g. `darwin-x64` from an `arm64` host) needs an explicit
|
|
40
|
+
`napi build --release --target x86_64-apple-darwin --cwd
|
|
41
|
+
../../crates/alien-bindings-node`.
|
|
42
|
+
|
|
43
|
+
To point the loader at an addon somewhere else, set `ALIEN_BINDINGS_ADDON_PATH`
|
|
44
|
+
to its path (step 1).
|
|
45
|
+
|
|
46
|
+
## Prebuild packages (`npm/`)
|
|
47
|
+
|
|
48
|
+
`npm/<triple>/` holds the skeleton for each published per-platform package
|
|
49
|
+
(`darwin-arm64`, `darwin-x64`, `linux-x64-gnu`, `linux-arm64-gnu`). Each carries
|
|
50
|
+
a `package.json` (`name`/`os`/`cpu`/`libc`/`main`/`files`) and a README; the
|
|
51
|
+
`.node` is staged in at build time and is never committed. There is no musl
|
|
52
|
+
target: the deployment base images are glibc (chainguard/wolfi-base), not Alpine.
|
|
53
|
+
|
|
54
|
+
The release pipeline builds each addon on its native runner, stages it into the
|
|
55
|
+
matching `npm/<triple>/` dir, rewrites the placeholder `0.0.0` versions to the
|
|
56
|
+
release version, injects the exact-version `optionalDependencies` into this
|
|
57
|
+
package's published manifest, and publishes the platform packages before the
|
|
58
|
+
wrapper. Pinning the exact version is what guarantees a published wrapper only
|
|
59
|
+
ever loads the matching-version platform addon.
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error definitions and napi error recovery for `@alienplatform/bindings`.
|
|
3
|
+
*
|
|
4
|
+
* The native addon runs every binding operation as an async napi method. napi
|
|
5
|
+
* constrains async errors to a fixed `Status` string, so `err.code` is always
|
|
6
|
+
* `"GenericFailure"` and carries no information. The addon instead serializes a
|
|
7
|
+
* structured envelope into the JS `err.message`:
|
|
8
|
+
*
|
|
9
|
+
* { code, message, context?, retryable }
|
|
10
|
+
*
|
|
11
|
+
* where `context` keys are snake_case (e.g. `binding_name`, `env_var`).
|
|
12
|
+
* `unwrapNapiError` recovers that envelope with a single `JSON.parse` — never by
|
|
13
|
+
* scraping the human message — and maps it to a typed {@link AlienError}.
|
|
14
|
+
*/
|
|
15
|
+
import { AlienError, defineError } from "@alienplatform/core";
|
|
16
|
+
import * as z from "zod/v4";
|
|
17
|
+
export { AlienError, defineError };
|
|
18
|
+
/**
|
|
19
|
+
* Thrown on the first operation against a binding that has no
|
|
20
|
+
* `ALIEN_<NAME>_BINDING` entry in the environment.
|
|
21
|
+
*
|
|
22
|
+
* `binding` is the binding name; `envVar` is the missing `ALIEN_<NAME>_BINDING`
|
|
23
|
+
* variable. Both are mapped from the addon envelope's snake_case
|
|
24
|
+
* `binding_name` / `env_var` context keys.
|
|
25
|
+
*/
|
|
26
|
+
export declare const BindingNotConfiguredError: {
|
|
27
|
+
metadata: import("@alienplatform/core").AlienErrorMetadata<z.ZodObject<{
|
|
28
|
+
binding: z.ZodString;
|
|
29
|
+
envVar: z.ZodString;
|
|
30
|
+
}, z.core.$strip>>;
|
|
31
|
+
contextSchema: z.ZodObject<{
|
|
32
|
+
binding: z.ZodString;
|
|
33
|
+
envVar: z.ZodString;
|
|
34
|
+
}, z.core.$strip>;
|
|
35
|
+
create: (context: {
|
|
36
|
+
binding: string;
|
|
37
|
+
envVar: string;
|
|
38
|
+
}) => import("@alienplatform/core").AlienErrorDefinition<z.ZodObject<{
|
|
39
|
+
binding: z.ZodString;
|
|
40
|
+
envVar: z.ZodString;
|
|
41
|
+
}, z.core.$strip>>;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Recover a typed {@link AlienError} from an error thrown by the native addon.
|
|
45
|
+
*
|
|
46
|
+
* - An error that is already an {@link AlienError} passes through unchanged.
|
|
47
|
+
* - A message carrying the addon envelope is decoded: `BINDING_NOT_CONFIGURED`
|
|
48
|
+
* becomes {@link BindingNotConfiguredError} (with `binding` / `envVar` mapped
|
|
49
|
+
* from the envelope's snake_case context); every other envelope code becomes a
|
|
50
|
+
* generic `AlienError` that preserves the `code`, `message`, `context`, and
|
|
51
|
+
* `retryable` flag.
|
|
52
|
+
* - A non-envelope message (napi-internal error) is wrapped as a generic
|
|
53
|
+
* `BINDINGS_ERROR`, preserving the original message.
|
|
54
|
+
*/
|
|
55
|
+
export declare function unwrapNapiError(err: unknown): AlienError;
|
|
56
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AAC7D,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAA;AAI3B,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,CAAA;AAElC;;;;;;;GAOG;AACH,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;CAWpC,CAAA;AAwCF;;;;;;;;;;;GAWG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,OAAO,GAAG,UAAU,CAsCxD"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The four binding factories, parameterized over how the native addon is
|
|
3
|
+
* obtained. `index.ts` binds them to the lazy {@link loadAddon}; `native.ts`
|
|
4
|
+
* binds them to a statically-embedded addon.
|
|
5
|
+
*
|
|
6
|
+
* Laziness contract: constructing a factory result performs no work. The first
|
|
7
|
+
* operation on a handle materializes the `BindingsHandle` and the resource
|
|
8
|
+
* handle exactly once, caches both, and every operation translates thrown napi
|
|
9
|
+
* errors through {@link unwrapNapiError}. A failed materialization is not
|
|
10
|
+
* cached, so a later call retries.
|
|
11
|
+
*
|
|
12
|
+
* Handle methods are closures (not `this`-bound class methods), so they behave
|
|
13
|
+
* correctly even when destructured off the handle (`const { get } = storage(x)`).
|
|
14
|
+
*/
|
|
15
|
+
import type { NativeAddon } from "./loader.js";
|
|
16
|
+
import type { Kv, Queue, Storage, Vault } from "./types.js";
|
|
17
|
+
/** The public factory surface. */
|
|
18
|
+
export interface Factories {
|
|
19
|
+
storage(name: string): Storage;
|
|
20
|
+
kv(name: string): Kv;
|
|
21
|
+
queue(name: string): Queue;
|
|
22
|
+
vault(name: string): Vault;
|
|
23
|
+
}
|
|
24
|
+
/** Build the four factories bound to a given addon provider. */
|
|
25
|
+
export declare function createFactories(getAddon: () => NativeAddon): Factories;
|
|
26
|
+
//# sourceMappingURL=factories.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"factories.d.ts","sourceRoot":"","sources":["../src/factories.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAGH,OAAO,KAAK,EACV,WAAW,EAMZ,MAAM,aAAa,CAAA;AACpB,OAAO,KAAK,EACV,EAAE,EAIF,KAAK,EAGL,OAAO,EACP,KAAK,EACN,MAAM,YAAY,CAAA;AA+HnB,kCAAkC;AAClC,MAAM,WAAW,SAAS;IACxB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAA;IAC9B,EAAE,CAAC,IAAI,EAAE,MAAM,GAAG,EAAE,CAAA;IACpB,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,KAAK,CAAA;IAC1B,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,KAAK,CAAA;CAC3B;AAED,gEAAgE;AAChE,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,WAAW,GAAG,SAAS,CAWtE"}
|