@runku/server 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.
package/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright 2026 Aldemi Tech
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,176 @@
1
+ # `@runku/server`
2
+
3
+ Declarative TypeScript SDK for schema, validators, indexes, Query/Mutation/Action, Cron, canonical
4
+ values, and capability-scoped Function context. Source under `runku/` is authoritative;
5
+ `runku build` extracts static metadata and generates client contracts.
6
+
7
+ The helper objects support TypeScript authoring. The Rust builder/runtime independently validate
8
+ metadata, contracts, capabilities, source policy, and values.
9
+
10
+ ```sh
11
+ npm install @runku/server
12
+ ```
13
+
14
+ ## Schema
15
+
16
+ Exactly one module under `runku/` must default-export a schema:
17
+
18
+ ```ts
19
+ import { defineSchema, defineTable, v } from "@runku/server"
20
+
21
+ export const note = v.object({
22
+ ownerId: v.string({ minBytes: 1, maxBytes: 256 }),
23
+ title: v.string({ minBytes: 1, maxBytes: 200 }),
24
+ archived: v.boolean(),
25
+ })
26
+
27
+ export default defineSchema({
28
+ notes: defineTable(note)
29
+ .index("by_owner", ["ownerId"])
30
+ .index("by_owner_archived", ["ownerId", "archived"]),
31
+ })
32
+ ```
33
+
34
+ `schema.tables.notes` is a typed table reference; `schema.indexes.notes.by_owner` is a typed index
35
+ reference. IDs are derived from Project and logical names. Never hard-code physical `tbl_*`/`idx_*`
36
+ values.
37
+
38
+ ## Validators
39
+
40
+ `v` exposes:
41
+
42
+ - `any`, `null`, `boolean`;
43
+ - `int64({ minimum, maximum })`, represented by `bigint`;
44
+ - `float64({ minimum, maximum })`, represented by `number`;
45
+ - `string({ minBytes, maxBytes })`, `bytes({ minBytes, maxBytes })`;
46
+ - `timestamp`, `id(kind?)`, `documentId(table)`;
47
+ - `array(item, { minItems, maxItems })`;
48
+ - `object(fields)`, `pick(object, keys)`, `union(...)`, `optional(value)`.
49
+
50
+ Use `Infer<typeof validator>` for helpers without duplicating interfaces. Bounds are part of the
51
+ runtime contract, not TypeScript-only documentation.
52
+
53
+ ## Functions
54
+
55
+ ```ts
56
+ import { mutation, v } from "@runku/server"
57
+ import schema, { note } from "./schema.js"
58
+
59
+ export const create = mutation({
60
+ auth: "user",
61
+ visibility: "public",
62
+ capabilities: ["auth:read", "db:read", "db:write"],
63
+ args: v.object({ title: v.string({ minBytes: 1, maxBytes: 200 }) }),
64
+ returns: v.object({ id: v.documentId("notes"), note }),
65
+ async handler(ctx, input) {
66
+ const principal = ctx.auth.principal
67
+ if (principal === null || principal.kind !== "user") throw new Error("user required")
68
+ const id = ctx.db.documentId(schema.tables.notes, ctx.invocation.invocationId)
69
+ const value = { ownerId: principal.id, title: input.title, archived: false }
70
+ await ctx.db.insert(schema.tables.notes, id, value)
71
+ return { id, note: value }
72
+ },
73
+ })
74
+ ```
75
+
76
+ All fields are required and statically extractable. `auth` is `none|optional|guest|user|service`;
77
+ `visibility` is `public|internal`.
78
+
79
+ ### Capability matrix
80
+
81
+ | Capability | Query | Mutation | Action | Context member |
82
+ |---|:---:|:---:|:---:|---|
83
+ | `db:read` | yes | yes | no | `ctx.db.get/documentId/scan` as applicable |
84
+ | `db:write` | no | yes | no | `ctx.db.insert/replace/delete` |
85
+ | `auth:read` | yes | yes | yes | `ctx.auth` |
86
+ | `function:query` | yes | yes | yes | `ctx.runQuery` |
87
+ | `function:mutation` | no | yes | yes | `ctx.runMutation` |
88
+ | `function:action` | no | no | yes | `ctx.runAction` |
89
+ | `network:https` | no | no | yes | `ctx.https.request` |
90
+ | `scheduler:create` | no | yes | yes | `ctx.scheduler.runAfter/runAt` |
91
+
92
+ Every context also exposes `ctx.invocation`, cooperative yield, and bounded structured `ctx.log`.
93
+
94
+ ## Data operations
95
+
96
+ Queries can `get`, derive a typed `documentId`, and `scan` a typed index with explicit bounds/limit.
97
+ Mutations read documents and `insert`, `replace(expectedRevision)`, or
98
+ `delete(expectedRevision)`. Mutation writes commit atomically with logical indexes, outbox, and
99
+ schedules. Actions access data through nested Query/Mutation instead of direct writes.
100
+
101
+ ## Full Node Actions
102
+
103
+ ```ts
104
+ "use runku node"
105
+
106
+ import { createHash } from "node:crypto"
107
+ import { action, v } from "@runku/server"
108
+
109
+ export const digest = action({
110
+ auth: "none",
111
+ visibility: "public",
112
+ capabilities: [],
113
+ args: v.string(),
114
+ returns: v.string(),
115
+ handler(_ctx, input) {
116
+ return createHash("sha256").update(input).digest("hex")
117
+ },
118
+ })
119
+ ```
120
+
121
+ The directive must be first and applies to the reachable module graph. It does not change the
122
+ declaration API. Query, Mutation, and Cron remain Safe. Cross-runtime calls use `ctx.run*`, not
123
+ Function imports. Remote OCI builds require `package-lock.json`.
124
+
125
+ ## HTTPS and scheduling
126
+
127
+ An Action with `network:https` calls the mediated HTTPS broker. A Mutation/Action with
128
+ `scheduler:create` can schedule an eligible Function:
129
+
130
+ ```ts
131
+ await ctx.scheduler.runAfter(
132
+ 5_000_000n,
133
+ "notifications.deliver",
134
+ argumentsValue,
135
+ { idempotencyKey: "notification:123" },
136
+ )
137
+ ```
138
+
139
+ Times are microseconds. Durable delivery is at-least-once; external effects require idempotency.
140
+
141
+ ## Cron and canonical constants
142
+
143
+ ```ts
144
+ import { cron, value } from "@runku/server"
145
+
146
+ export const hourly = cron({
147
+ schedule: "0 * * * *",
148
+ function: "maintenance.compact",
149
+ args: { attempt: value.int64(1n) },
150
+ })
151
+ ```
152
+
153
+ `value.int64`, `float64`, `timestamp`, `id`, and `bytes` represent non-JSON canonical constants in
154
+ Cron arguments.
155
+
156
+ ## Source constraints
157
+
158
+ Safe source accepts static relative imports inside `runku/` plus `@runku/server`. Dynamic imports,
159
+ path escapes, source symlinks, ambiguous re-exports, top-level await, unsupported runtime mixing,
160
+ and computed declaration metadata fail closed. Full Node may resolve built-ins/npm within its
161
+ isolated module graph.
162
+
163
+ ## Generated client registry
164
+
165
+ `runku build` writes immutable Release-specific types and updates
166
+ `runku/_generated/api.d.ts`. It includes public/internal Function kind, visibility, canonical
167
+ arguments, and result types. Do not edit it.
168
+
169
+ ## Development
170
+
171
+ ```sh
172
+ pnpm --dir packages/server check
173
+ ```
174
+
175
+ The package check builds and runs type conformance. Changes to declarations also require builder,
176
+ runtime, generated-contract, and example gates described in [`AGENTS.md`](../../AGENTS.md).
@@ -0,0 +1,314 @@
1
+ /** Canonical timestamp in signed microseconds. */
2
+ export interface RunkuTimestamp {
3
+ readonly value: bigint;
4
+ toString(): string;
5
+ }
6
+ /** Canonical typed Runku identifier. */
7
+ export interface RunkuId {
8
+ readonly value: string;
9
+ toString(): string;
10
+ }
11
+ declare const documentTableBrand: unique symbol;
12
+ declare const tableReferenceBrand: unique symbol;
13
+ declare const indexReferenceBrand: unique symbol;
14
+ /** Canonical Document ID statically associated with one logical schema table. */
15
+ export type DocumentId<TableName extends string> = RunkuId & {
16
+ readonly [documentTableBrand]: TableName;
17
+ };
18
+ /** Values accepted and returned by the declarative `runku-js-1` runtime. */
19
+ export type RunkuValue = null | boolean | bigint | number | string | Uint8Array | RunkuTimestamp | RunkuId | readonly RunkuValue[] | {
20
+ readonly [key: string]: RunkuValue;
21
+ };
22
+ /** Platform capability names implemented by the safe runtime. */
23
+ export type ImplementedCapability = "db:read" | "db:write" | "auth:read" | "function:query" | "function:mutation" | "function:action" | "network:https" | "scheduler:create";
24
+ export type QueryCapability = Extract<ImplementedCapability, "db:read" | "auth:read" | "function:query">;
25
+ export type MutationCapability = Extract<ImplementedCapability, "db:read" | "db:write" | "auth:read" | "function:query" | "function:mutation" | "scheduler:create">;
26
+ export type ActionCapability = Extract<ImplementedCapability, "auth:read" | "function:query" | "function:mutation" | "function:action" | "network:https" | "scheduler:create">;
27
+ export interface InvocationMetadata {
28
+ readonly projectId: string;
29
+ readonly environmentId: string;
30
+ readonly releaseId: string;
31
+ readonly requestId: string;
32
+ readonly invocationId: string;
33
+ readonly functionId: string;
34
+ readonly functionName: string;
35
+ readonly functionType: "query" | "mutation" | "action";
36
+ readonly capabilities: readonly string[];
37
+ readonly httpsEnabled: boolean;
38
+ readonly dataEnabled: boolean;
39
+ readonly dataWriteEnabled: boolean;
40
+ readonly schedulerEnabled: boolean;
41
+ readonly functionQueryEnabled: boolean;
42
+ readonly functionMutationEnabled: boolean;
43
+ readonly functionActionEnabled: boolean;
44
+ readonly authEnabled: boolean;
45
+ }
46
+ export interface ApplicationContext {
47
+ readonly clientId: string;
48
+ readonly credentialId: string;
49
+ readonly assurance: "declared" | "verified";
50
+ readonly scopes: readonly string[];
51
+ readonly configurationRevision: bigint;
52
+ }
53
+ export interface PrincipalContext {
54
+ readonly id: string;
55
+ readonly kind: "guest" | "user" | "service" | "system";
56
+ readonly providerId: string;
57
+ readonly scopes: readonly string[];
58
+ readonly authTime: RunkuTimestamp | null;
59
+ readonly expiresAt: RunkuTimestamp | null;
60
+ readonly mappingRevision: bigint;
61
+ }
62
+ export interface AuthContext {
63
+ readonly application: ApplicationContext | null;
64
+ readonly principal: PrincipalContext | null;
65
+ }
66
+ export interface DataDocument<T extends RunkuValue = RunkuValue, TableName extends string = string> {
67
+ readonly tableId: string;
68
+ readonly documentId: DocumentId<TableName>;
69
+ readonly revision: bigint;
70
+ readonly commitSequence: bigint;
71
+ readonly createdAt: RunkuTimestamp;
72
+ readonly updatedAt: RunkuTimestamp;
73
+ readonly value: T;
74
+ }
75
+ export interface DataIndexEntry<TableName extends string = string> {
76
+ readonly indexId: string;
77
+ readonly key: Uint8Array;
78
+ readonly tableId: string;
79
+ readonly documentId: DocumentId<TableName>;
80
+ readonly documentRevision: bigint;
81
+ readonly commitSequence: bigint;
82
+ }
83
+ export interface DataRangeBound {
84
+ readonly kind: "inclusive" | "exclusive";
85
+ readonly key: Uint8Array;
86
+ }
87
+ export interface QueryDatabase {
88
+ get<Name extends string, T extends RunkuValue, I extends string>(table: TableReference<Name, T, I>, documentId: DocumentId<NoInfer<Name>>): Promise<DataDocument<T, Name> | null>;
89
+ documentId<Name extends string, T extends RunkuValue, I extends string>(table: TableReference<Name, T, I>, stableKey: string): DocumentId<Name>;
90
+ scan<Name extends string, I extends string, IndexName extends I>(index: IndexReference<Name, IndexName>, options: {
91
+ readonly lower?: DataRangeBound | null;
92
+ readonly upper?: DataRangeBound | null;
93
+ readonly limit: number;
94
+ }): Promise<readonly DataIndexEntry<Name>[]>;
95
+ }
96
+ export interface MutationReadDatabase {
97
+ get<Name extends string, T extends RunkuValue, I extends string>(table: TableReference<Name, T, I>, documentId: DocumentId<NoInfer<Name>>): Promise<DataDocument<T, Name> | null>;
98
+ documentId<Name extends string, T extends RunkuValue, I extends string>(table: TableReference<Name, T, I>, stableKey: string): DocumentId<Name>;
99
+ }
100
+ export interface MutationWriteDatabase {
101
+ insert<Name extends string, T extends RunkuValue, I extends string>(table: TableReference<Name, T, I>, documentId: DocumentId<NoInfer<Name>>, value: NoInfer<T>): Promise<void>;
102
+ replace<Name extends string, T extends RunkuValue, I extends string>(table: TableReference<Name, T, I>, documentId: DocumentId<NoInfer<Name>>, expectedRevision: bigint, value: NoInfer<T>): Promise<void>;
103
+ delete<Name extends string, T extends RunkuValue, I extends string>(table: TableReference<Name, T, I>, documentId: DocumentId<NoInfer<Name>>, expectedRevision: bigint): Promise<void>;
104
+ }
105
+ export interface HttpsRequest {
106
+ readonly method: "GET" | "HEAD" | "POST" | "PUT" | "PATCH" | "DELETE";
107
+ readonly url: string;
108
+ readonly headers?: Readonly<Record<string, readonly string[]>>;
109
+ readonly body?: Uint8Array;
110
+ readonly idempotencyKey?: string;
111
+ }
112
+ export interface HttpsResponse {
113
+ readonly status: number;
114
+ readonly headers: Readonly<Record<string, readonly string[]>>;
115
+ readonly body: Uint8Array;
116
+ }
117
+ export interface HttpsClient {
118
+ request(input: HttpsRequest): Promise<HttpsResponse>;
119
+ }
120
+ export interface ScheduleOptions {
121
+ readonly idempotencyKey?: string;
122
+ }
123
+ export interface Scheduler {
124
+ runAfter(delayMicros: bigint, functionName: string, argumentsValue: RunkuValue, options?: ScheduleOptions): Promise<string>;
125
+ runAt(timestampMicros: bigint, functionName: string, argumentsValue: RunkuValue, options?: ScheduleOptions): Promise<string>;
126
+ }
127
+ /** Bounded best-effort structured Function logger. */
128
+ export interface FunctionLogger {
129
+ debug(message: string, fields?: Readonly<Record<string, RunkuValue>>): Promise<void>;
130
+ info(message: string, fields?: Readonly<Record<string, RunkuValue>>): Promise<void>;
131
+ warn(message: string, fields?: Readonly<Record<string, RunkuValue>>): Promise<void>;
132
+ error(message: string, fields?: Readonly<Record<string, RunkuValue>>): Promise<void>;
133
+ }
134
+ interface BaseContext {
135
+ readonly invocation: InvocationMetadata;
136
+ readonly cooperate: () => Promise<void>;
137
+ readonly log: FunctionLogger;
138
+ }
139
+ type AuthFeature<C extends ImplementedCapability> = "auth:read" extends C ? {
140
+ readonly auth: AuthContext;
141
+ } : Record<never, never>;
142
+ type QueryDataFeature<C extends QueryCapability> = "db:read" extends C ? {
143
+ readonly db: QueryDatabase;
144
+ } : Record<never, never>;
145
+ type MutationDataFeature<C extends MutationCapability> = ("db:read" extends C ? MutationReadDatabase : Record<never, never>) & ("db:write" extends C ? MutationWriteDatabase : Record<never, never>) extends infer D ? [keyof D] extends [never] ? Record<never, never> : {
146
+ readonly db: D;
147
+ } : never;
148
+ type HttpsFeature<C extends ActionCapability> = "network:https" extends C ? {
149
+ readonly https: HttpsClient;
150
+ } : Record<never, never>;
151
+ type SchedulerFeature<C extends MutationCapability | ActionCapability> = "scheduler:create" extends C ? {
152
+ readonly scheduler: Scheduler;
153
+ } : Record<never, never>;
154
+ type RunQueryFeature<C extends ImplementedCapability> = "function:query" extends C ? {
155
+ readonly runQuery: (functionName: string, argumentsValue: RunkuValue) => Promise<RunkuValue>;
156
+ } : Record<never, never>;
157
+ type RunMutationFeature<C extends ImplementedCapability> = "function:mutation" extends C ? {
158
+ readonly runMutation: (functionName: string, argumentsValue: RunkuValue) => Promise<RunkuValue>;
159
+ } : Record<never, never>;
160
+ type RunActionFeature<C extends ImplementedCapability> = "function:action" extends C ? {
161
+ readonly runAction: (functionName: string, argumentsValue: RunkuValue) => Promise<RunkuValue>;
162
+ } : Record<never, never>;
163
+ export type QueryContext<C extends QueryCapability> = BaseContext & AuthFeature<C> & QueryDataFeature<C> & RunQueryFeature<C>;
164
+ export type MutationContext<C extends MutationCapability> = BaseContext & AuthFeature<C> & MutationDataFeature<C> & SchedulerFeature<C> & RunQueryFeature<C> & RunMutationFeature<C>;
165
+ export type ActionContext<C extends ActionCapability> = BaseContext & AuthFeature<C> & HttpsFeature<C> & SchedulerFeature<C> & RunQueryFeature<C> & RunMutationFeature<C> & RunActionFeature<C>;
166
+ export type QueryHandler<C extends QueryCapability, A extends RunkuValue, R extends RunkuValue> = (context: QueryContext<C>, argumentsValue: A) => R | Promise<R>;
167
+ export type MutationHandler<C extends MutationCapability, A extends RunkuValue, R extends RunkuValue> = (context: MutationContext<C>, argumentsValue: A) => R | Promise<R>;
168
+ export type ActionHandler<C extends ActionCapability, A extends RunkuValue, R extends RunkuValue> = (context: ActionContext<C>, argumentsValue: A) => R | Promise<R>;
169
+ /** Statically extractable value contract used by the Runku source compiler. */
170
+ export interface Validator<T extends RunkuValue = RunkuValue> {
171
+ readonly __runkuValidator: true;
172
+ readonly __value?: T;
173
+ }
174
+ export interface OptionalValidator<T extends RunkuValue = RunkuValue> extends Validator<T> {
175
+ readonly __runkuOptional: true;
176
+ }
177
+ /** Infers the canonical TypeScript value represented by one validator. */
178
+ export type Infer<V extends Validator> = V extends Validator<infer T> ? T : never;
179
+ type ValidatorValue<V extends Validator> = Infer<V>;
180
+ type ValidatorShape = Readonly<Record<string, Validator>>;
181
+ type OptionalKeys<S extends ValidatorShape> = {
182
+ [K in keyof S]-?: S[K] extends OptionalValidator ? K : never;
183
+ }[keyof S];
184
+ type ObjectValue<S extends ValidatorShape> = {
185
+ readonly [K in Exclude<keyof S, OptionalKeys<S>>]: ValidatorValue<S[K]>;
186
+ } & {
187
+ readonly [K in OptionalKeys<S>]?: ValidatorValue<S[K]>;
188
+ };
189
+ export interface ObjectValidator<S extends ValidatorShape> extends Validator<ObjectValue<S>> {
190
+ readonly __shape?: S;
191
+ }
192
+ export interface BoundOptions {
193
+ readonly minimum?: number;
194
+ readonly maximum?: number;
195
+ }
196
+ export interface ByteBoundOptions {
197
+ readonly minBytes?: number;
198
+ readonly maxBytes?: number;
199
+ }
200
+ export interface ItemBoundOptions {
201
+ readonly minItems?: number;
202
+ readonly maxItems?: number;
203
+ }
204
+ /** Declarative validators understood statically by `runku build`. */
205
+ export declare const v: Readonly<{
206
+ any: () => Validator<RunkuValue>;
207
+ null: () => Validator<null>;
208
+ boolean: () => Validator<boolean>;
209
+ int64: (_options?: BoundOptions) => Validator<bigint>;
210
+ float64: (_options?: BoundOptions) => Validator<number>;
211
+ string: (_options?: ByteBoundOptions) => Validator<string>;
212
+ bytes: (_options?: ByteBoundOptions) => Validator<Uint8Array>;
213
+ timestamp: () => Validator<RunkuTimestamp>;
214
+ id: <const K extends string>(_kind?: K) => Validator<RunkuId>;
215
+ documentId: <const TableName extends string>(_table: TableName) => Validator<DocumentId<TableName>>;
216
+ array: <V extends Validator>(_items: V, _options?: ItemBoundOptions) => Validator<readonly ValidatorValue<V>[]>;
217
+ object: <S extends ValidatorShape>(_fields: S) => ObjectValidator<S>;
218
+ pick: <S extends ValidatorShape, const K extends readonly (keyof S & string)[]>(_object: ObjectValidator<S>, _keys: K) => ObjectValidator<Pick<S, K[number]>>;
219
+ union: <const V extends readonly [Validator, Validator, ...Validator[]]>(..._variants: V) => Validator<ValidatorValue<V[number]>>;
220
+ optional: <V extends Validator>(_value: V) => OptionalValidator<ValidatorValue<V>>;
221
+ }>;
222
+ export type FunctionAuth = "none" | "optional" | "guest" | "user" | "service";
223
+ export type FunctionVisibility = "public" | "internal";
224
+ export interface FunctionDefinition<K extends "query" | "mutation" | "action", A extends RunkuValue, R extends RunkuValue> {
225
+ readonly __runkuFunction: K;
226
+ readonly __arguments?: A;
227
+ readonly __result?: R;
228
+ }
229
+ type CommonDefinition<A extends Validator, R extends Validator> = {
230
+ readonly auth: FunctionAuth;
231
+ readonly visibility: FunctionVisibility;
232
+ readonly args: A;
233
+ readonly returns: R;
234
+ };
235
+ export declare function query<const C extends readonly QueryCapability[], A extends Validator, R extends Validator>(definition: CommonDefinition<A, R> & {
236
+ readonly capabilities: C;
237
+ readonly handler: QueryHandler<C[number], ValidatorValue<A>, ValidatorValue<R>>;
238
+ }): FunctionDefinition<"query", ValidatorValue<A>, ValidatorValue<R>>;
239
+ export declare function mutation<const C extends readonly MutationCapability[], A extends Validator, R extends Validator>(definition: CommonDefinition<A, R> & {
240
+ readonly capabilities: C;
241
+ readonly handler: MutationHandler<C[number], ValidatorValue<A>, ValidatorValue<R>>;
242
+ }): FunctionDefinition<"mutation", ValidatorValue<A>, ValidatorValue<R>>;
243
+ export declare function action<const C extends readonly ActionCapability[], A extends Validator, R extends Validator>(definition: CommonDefinition<A, R> & {
244
+ readonly capabilities: C;
245
+ readonly handler: ActionHandler<C[number], ValidatorValue<A>, ValidatorValue<R>>;
246
+ }): FunctionDefinition<"action", ValidatorValue<A>, ValidatorValue<R>>;
247
+ export interface CronDefinition {
248
+ readonly __runkuCron: true;
249
+ }
250
+ /** Statically compiled UTC schedule. Its export name becomes the stable Cron name. */
251
+ export declare function cron(definition: {
252
+ readonly schedule: string;
253
+ readonly function: string;
254
+ readonly args: RunkuValue;
255
+ }): CronDefinition;
256
+ /** Explicit constructors for non-JSON values embedded in Cron arguments. */
257
+ export declare const value: Readonly<{
258
+ int64: (input: bigint) => bigint;
259
+ float64: (input: number) => number;
260
+ timestamp: (micros: bigint) => RunkuTimestamp;
261
+ id: (input: string) => RunkuId;
262
+ bytes: (input: readonly number[]) => Uint8Array;
263
+ }>;
264
+ export interface IndexDeclaration {
265
+ readonly name: string;
266
+ readonly fields: readonly string[];
267
+ }
268
+ export interface TableDefinition<T extends RunkuValue = RunkuValue, I extends string = never> {
269
+ readonly __runkuTable: true;
270
+ readonly document: Validator<T>;
271
+ readonly indexes: readonly IndexDeclaration[];
272
+ index<const N extends string>(name: N, fields: readonly (keyof T & string)[]): TableDefinition<T, I | N>;
273
+ }
274
+ export declare function defineTable<V extends Validator>(document: V): TableDefinition<ValidatorValue<V>, never>;
275
+ type TableMap = Readonly<Record<string, TableDefinition<RunkuValue, string>>>;
276
+ export type TableReference<Name extends string, T extends RunkuValue, IndexName extends string = never> = string & {
277
+ readonly [tableReferenceBrand]: {
278
+ readonly name: Name;
279
+ readonly document: T;
280
+ readonly indexes: IndexName;
281
+ };
282
+ };
283
+ export type IndexReference<TableName extends string, IndexName extends string> = string & {
284
+ readonly [indexReferenceBrand]: {
285
+ readonly table: TableName;
286
+ readonly index: IndexName;
287
+ };
288
+ };
289
+ type TableValue<T> = T extends TableDefinition<infer V, string> ? V : never;
290
+ type TableReferences<T extends TableMap> = {
291
+ readonly [K in keyof T & string]: TableReference<K, TableValue<T[K]>, IndexNames<T[K]>>;
292
+ };
293
+ type IndexNames<T> = T extends TableDefinition<RunkuValue, infer I> ? I : never;
294
+ type IndexReferences<T extends TableMap> = {
295
+ readonly [K in keyof T & string]: {
296
+ readonly [I in IndexNames<T[K]>]: IndexReference<K, I>;
297
+ };
298
+ };
299
+ export interface SchemaDefinition<T extends TableMap = TableMap> {
300
+ readonly __runkuSchema: true;
301
+ readonly definitions: T;
302
+ readonly tables: TableReferences<T>;
303
+ readonly indexes: IndexReferences<T>;
304
+ }
305
+ export declare function defineSchema<const T extends TableMap>(definitions: T): SchemaDefinition<T>;
306
+ export interface RunkuGlobals {
307
+ timestamp(micros: bigint | number | string): RunkuTimestamp;
308
+ id(value: string): RunkuId;
309
+ }
310
+ declare global {
311
+ const Runku: RunkuGlobals;
312
+ }
313
+ export {};
314
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,kDAAkD;AAClD,MAAM,WAAW,cAAc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: () => validator(),
4
+ null: () => validator(),
5
+ boolean: () => validator(),
6
+ int64: (_options = {}) => validator(),
7
+ float64: (_options = {}) => validator(),
8
+ string: (_options = {}) => validator(),
9
+ bytes: (_options = {}) => validator(),
10
+ timestamp: () => validator(),
11
+ id: (_kind) => validator(),
12
+ documentId: (_table) => validator(),
13
+ array: (_items, _options = {}) => validator(),
14
+ object: (_fields) => validator(),
15
+ pick: (_object, _keys) => validator(),
16
+ union: (..._variants) => validator(),
17
+ optional: (_value) => Object.freeze({ __runkuValidator: true, __runkuOptional: true }),
18
+ });
19
+ function validator() {
20
+ return Object.freeze({ __runkuValidator: true });
21
+ }
22
+ export function query(definition) {
23
+ return functionDefinition("query", definition);
24
+ }
25
+ export function mutation(definition) {
26
+ return functionDefinition("mutation", definition);
27
+ }
28
+ export function action(definition) {
29
+ return functionDefinition("action", definition);
30
+ }
31
+ /** Statically compiled UTC schedule. Its export name becomes the stable Cron name. */
32
+ export function cron(definition) {
33
+ return Object.freeze({ __runkuCron: true, ...definition });
34
+ }
35
+ /** Explicit constructors for non-JSON values embedded in Cron arguments. */
36
+ export const value = Object.freeze({
37
+ int64: (input) => input,
38
+ float64: (input) => input,
39
+ timestamp: (micros) => Runku.timestamp(micros),
40
+ id: (input) => Runku.id(input),
41
+ bytes: (input) => new Uint8Array(input),
42
+ });
43
+ function functionDefinition(kind, definition) {
44
+ return Object.freeze({ __runkuFunction: kind, ...definition });
45
+ }
46
+ export function defineTable(document) {
47
+ const indexes = [];
48
+ const table = {
49
+ __runkuTable: true,
50
+ document: document,
51
+ indexes,
52
+ index(name, fields) {
53
+ indexes.push(Object.freeze({ name, fields: Object.freeze([...fields]) }));
54
+ return table;
55
+ },
56
+ };
57
+ return table;
58
+ }
59
+ export function defineSchema(definitions) {
60
+ const tables = Object.fromEntries(Object.keys(definitions).map((name) => [name, name]));
61
+ const indexes = Object.fromEntries(Object.entries(definitions).map(([name, table]) => [
62
+ name,
63
+ Object.fromEntries(table.indexes.map((index) => [index.name, `${name}.${index.name}`])),
64
+ ]));
65
+ return Object.freeze({ __runkuSchema: true, definitions, tables, indexes });
66
+ }
67
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAqWA,qEAAqE;AACrE,MAAM,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC;IAC7B,GAAG,EAAE,GAA0B,EAAE,CAAC,SAAS,EAAE;IAC7C,IAAI,EAAE,GAAoB,EAAE,CAAC,SAAS,EAAE;IACxC,OAAO,EAAE,GAAuB,EAAE,CAAC,SAAS,EAAE;IAC9C,KAAK,EAAE,CAAC,QAAQ,GAAiB,EAAE,EAAqB,EAAE,CAAC,SAAS,EAAE;IACtE,OAAO,EAAE,CAAC,QAAQ,GAAiB,EAAE,EAAqB,EAAE,CAAC,SAAS,EAAE;IACxE,MAAM,EAAE,CAAC,QAAQ,GAAqB,EAAE,EAAqB,EAAE,CAAC,SAAS,EAAE;IAC3E,KAAK,EAAE,CAAC,QAAQ,GAAqB,EAAE,EAAyB,EAAE,CAAC,SAAS,EAAE;IAC9E,SAAS,EAAE,GAA8B,EAAE,CAAC,SAAS,EAAE;IACvD,EAAE,EAAE,CAAyB,KAAS,EAAsB,EAAE,CAAC,SAAS,EAAE;IAC1E,UAAU,EAAE,CACV,MAAiB,EACiB,EAAE,CAAC,SAAS,EAAE;IAClD,KAAK,EAAE,CACL,MAAS,EACT,QAAQ,GAAqB,EAAE,EACU,EAAE,CAAC,SAAS,EAAE;IACzD,MAAM,EAAE,CAA2B,OAAU,EAAsB,EAAE,CAAC,SAAS,EAAE;IACjF,IAAI,EAAE,CACJ,OAA2B,EAC3B,KAAQ,EAC6B,EAAE,CAAC,SAAS,EAAE;IACrD,KAAK,EAAE,CACL,GAAG,SAAY,EACuB,EAAE,CAAC,SAAS,EAAE;IACtD,QAAQ,EAAE,CAAsB,MAAS,EAAwC,EAAE,CACjF,MAAM,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
package/package.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "@runku/server",
3
+ "version": "0.1.0",
4
+ "description": "Declarative Function, schema and Cron SDK for Runku",
5
+ "type": "module",
6
+ "license": "Apache-2.0",
7
+ "homepage": "https://github.com/aldemi-tech/runku/tree/main/packages/server#readme",
8
+ "bugs": {
9
+ "url": "https://github.com/aldemi-tech/runku/issues"
10
+ },
11
+ "keywords": ["runku", "server", "typescript", "functions", "schema"],
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "git+https://github.com/aldemi-tech/runku.git",
15
+ "directory": "packages/server"
16
+ },
17
+ "files": [
18
+ "dist"
19
+ ],
20
+ "exports": {
21
+ ".": {
22
+ "types": "./dist/index.d.ts",
23
+ "default": "./dist/index.js"
24
+ }
25
+ },
26
+ "types": "./dist/index.d.ts",
27
+ "publishConfig": {
28
+ "access": "public",
29
+ "registry": "https://registry.npmjs.org"
30
+ },
31
+ "scripts": {
32
+ "build": "tsc -p tsconfig.json",
33
+ "typecheck": "tsc -p tsconfig.check.json",
34
+ "lint": "tsc -p tsconfig.check.json",
35
+ "check": "pnpm typecheck && pnpm lint && pnpm build"
36
+ },
37
+ "devDependencies": {
38
+ "typescript": "7.0.2"
39
+ },
40
+ "engines": {
41
+ "node": ">=20"
42
+ }
43
+ }