@gigadrive/sdk 0.3.0 → 0.5.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/README.md +45 -0
- package/dist/index.d.mts +290 -1
- package/dist/index.d.ts +290 -1
- package/dist/index.js +157 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +154 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -2027,6 +2027,83 @@ var OrganizationEnvVarsResource = class extends BaseResource {
|
|
|
2027
2027
|
}
|
|
2028
2028
|
};
|
|
2029
2029
|
|
|
2030
|
+
// src/resources/organization-members.ts
|
|
2031
|
+
var OrganizationMembersResource = class extends BaseResource {
|
|
2032
|
+
/**
|
|
2033
|
+
* List the users who belong to an organization.
|
|
2034
|
+
*
|
|
2035
|
+
* @param organizationId - Organization whose members should be listed.
|
|
2036
|
+
* @param query - Optional pagination.
|
|
2037
|
+
* @returns A paginated list of organization members.
|
|
2038
|
+
*
|
|
2039
|
+
* @example
|
|
2040
|
+
* ```ts
|
|
2041
|
+
* const { items, total } = await client.organizations.members.list('org-id');
|
|
2042
|
+
* console.log(`Found ${total} members`);
|
|
2043
|
+
* ```
|
|
2044
|
+
*/
|
|
2045
|
+
async list(organizationId, query) {
|
|
2046
|
+
return this.httpClient.get(`/organizations/${organizationId}/members`, {
|
|
2047
|
+
query
|
|
2048
|
+
});
|
|
2049
|
+
}
|
|
2050
|
+
};
|
|
2051
|
+
|
|
2052
|
+
// src/resources/organization-products.ts
|
|
2053
|
+
var OrganizationProductsResource = class extends BaseResource {
|
|
2054
|
+
/**
|
|
2055
|
+
* List effective product access for every organization-scoped product.
|
|
2056
|
+
*
|
|
2057
|
+
* @param organizationId - Organization whose product access should be listed.
|
|
2058
|
+
* @param query - Optional pagination.
|
|
2059
|
+
* @returns A paginated list of product access summaries.
|
|
2060
|
+
*
|
|
2061
|
+
* @example
|
|
2062
|
+
* ```ts
|
|
2063
|
+
* const { items } = await client.organizations.products.list('org-id');
|
|
2064
|
+
* for (const item of items) {
|
|
2065
|
+
* console.log(item.product.slug, item.hasAccess);
|
|
2066
|
+
* }
|
|
2067
|
+
* ```
|
|
2068
|
+
*/
|
|
2069
|
+
async list(organizationId, query) {
|
|
2070
|
+
return this.httpClient.get(`/organizations/${organizationId}/products`, {
|
|
2071
|
+
query
|
|
2072
|
+
});
|
|
2073
|
+
}
|
|
2074
|
+
/**
|
|
2075
|
+
* Get effective access for one organization-scoped product.
|
|
2076
|
+
*
|
|
2077
|
+
* @param organizationId - Organization to inspect.
|
|
2078
|
+
* @param product - Product slug from the product registry.
|
|
2079
|
+
* @returns Product access summary including entitlement and subscription state.
|
|
2080
|
+
*
|
|
2081
|
+
* @example
|
|
2082
|
+
* ```ts
|
|
2083
|
+
* const access = await client.organizations.products.get('org-id', 'office');
|
|
2084
|
+
* console.log(access.hasAccess, access.subscription?.plan);
|
|
2085
|
+
* ```
|
|
2086
|
+
*/
|
|
2087
|
+
async get(organizationId, product) {
|
|
2088
|
+
return this.httpClient.get(`/organizations/${organizationId}/products/${product}`);
|
|
2089
|
+
}
|
|
2090
|
+
/**
|
|
2091
|
+
* Check whether an organization currently has access to a product.
|
|
2092
|
+
*
|
|
2093
|
+
* @param organizationId - Organization to check.
|
|
2094
|
+
* @param product - Product slug from the product registry.
|
|
2095
|
+
* @returns Compact entitlement check result.
|
|
2096
|
+
*
|
|
2097
|
+
* @example
|
|
2098
|
+
* ```ts
|
|
2099
|
+
* const { hasAccess } = await client.organizations.products.checkEntitlement('org-id', 'network');
|
|
2100
|
+
* ```
|
|
2101
|
+
*/
|
|
2102
|
+
async checkEntitlement(organizationId, product) {
|
|
2103
|
+
return this.httpClient.get(`/organizations/${organizationId}/products/${product}/entitlement`);
|
|
2104
|
+
}
|
|
2105
|
+
};
|
|
2106
|
+
|
|
2030
2107
|
// src/resources/organizations.ts
|
|
2031
2108
|
var OrganizationsResource = class extends BaseResource {
|
|
2032
2109
|
/**
|
|
@@ -2057,10 +2134,31 @@ var OrganizationsResource = class extends BaseResource {
|
|
|
2057
2134
|
* ```
|
|
2058
2135
|
*/
|
|
2059
2136
|
aiGateway;
|
|
2137
|
+
/**
|
|
2138
|
+
* List organization members and membership roles.
|
|
2139
|
+
*
|
|
2140
|
+
* @example
|
|
2141
|
+
* ```ts
|
|
2142
|
+
* const { items } = await client.organizations.members.list('org-id');
|
|
2143
|
+
* ```
|
|
2144
|
+
*/
|
|
2145
|
+
members;
|
|
2146
|
+
/**
|
|
2147
|
+
* Inspect organization product entitlements. Read-only through the public
|
|
2148
|
+
* API — plan changes happen in Gigadrive product surfaces, not via the SDK.
|
|
2149
|
+
*
|
|
2150
|
+
* @example
|
|
2151
|
+
* ```ts
|
|
2152
|
+
* const check = await client.organizations.products.checkEntitlement('org-id', 'office');
|
|
2153
|
+
* ```
|
|
2154
|
+
*/
|
|
2155
|
+
products;
|
|
2060
2156
|
constructor(...args) {
|
|
2061
2157
|
super(...args);
|
|
2062
2158
|
this.envVars = new OrganizationEnvVarsResource(this.httpClient);
|
|
2063
2159
|
this.aiGateway = new OrganizationAiGatewayResource(this.httpClient);
|
|
2160
|
+
this.members = new OrganizationMembersResource(this.httpClient);
|
|
2161
|
+
this.products = new OrganizationProductsResource(this.httpClient);
|
|
2064
2162
|
}
|
|
2065
2163
|
/**
|
|
2066
2164
|
* List organizations the authenticated actor has access to.
|
|
@@ -2079,6 +2177,56 @@ var OrganizationsResource = class extends BaseResource {
|
|
|
2079
2177
|
query
|
|
2080
2178
|
});
|
|
2081
2179
|
}
|
|
2180
|
+
/**
|
|
2181
|
+
* Get a single organization by ID.
|
|
2182
|
+
*
|
|
2183
|
+
* @param organizationId - Organization to retrieve.
|
|
2184
|
+
* @returns The organization.
|
|
2185
|
+
*
|
|
2186
|
+
* @example
|
|
2187
|
+
* ```ts
|
|
2188
|
+
* const org = await client.organizations.get('org-id');
|
|
2189
|
+
* console.log(org.name, org.slug);
|
|
2190
|
+
* ```
|
|
2191
|
+
*/
|
|
2192
|
+
async get(organizationId) {
|
|
2193
|
+
return this.httpClient.get(`/organizations/${organizationId}`);
|
|
2194
|
+
}
|
|
2195
|
+
/**
|
|
2196
|
+
* Create a new organization.
|
|
2197
|
+
*
|
|
2198
|
+
* Requires a user-backed token with the `platform:organizations:write` scope.
|
|
2199
|
+
* The authenticated user becomes the organization owner.
|
|
2200
|
+
*
|
|
2201
|
+
* @param input - Organization creation input.
|
|
2202
|
+
* @returns The created organization.
|
|
2203
|
+
*
|
|
2204
|
+
* @example
|
|
2205
|
+
* ```ts
|
|
2206
|
+
* const org = await client.organizations.create({ name: 'Acme Corp' });
|
|
2207
|
+
* console.log(org.id, org.slug);
|
|
2208
|
+
* ```
|
|
2209
|
+
*/
|
|
2210
|
+
async create(input) {
|
|
2211
|
+
return this.httpClient.post("/organizations", input);
|
|
2212
|
+
}
|
|
2213
|
+
};
|
|
2214
|
+
|
|
2215
|
+
// src/resources/sticky-sessions.ts
|
|
2216
|
+
var StickySessionsResource = class extends BaseResource {
|
|
2217
|
+
/**
|
|
2218
|
+
* Mints a signed URL for an opaque application key.
|
|
2219
|
+
*
|
|
2220
|
+
* Deployed Gigadrive workloads can call this with a zero-config
|
|
2221
|
+
* `GigadriveClient`; the platform injects `GIGADRIVE_CLIENT_ID` and
|
|
2222
|
+
* `GIGADRIVE_CLIENT_SECRET` using the SDK's existing credential chain.
|
|
2223
|
+
*/
|
|
2224
|
+
async createUrl(input) {
|
|
2225
|
+
return this.httpClient.post("/sticky-sessions/urls", {
|
|
2226
|
+
...input,
|
|
2227
|
+
method: input.method ?? "GET"
|
|
2228
|
+
});
|
|
2229
|
+
}
|
|
2082
2230
|
};
|
|
2083
2231
|
|
|
2084
2232
|
// src/client.ts
|
|
@@ -2094,6 +2242,8 @@ var GigadriveClient = class {
|
|
|
2094
2242
|
aiGateway;
|
|
2095
2243
|
/** Application-scoped API key management (create, list, revoke). */
|
|
2096
2244
|
apiKeys;
|
|
2245
|
+
/** Signed URLs that keep related requests on one MicroVM instance. */
|
|
2246
|
+
stickySessions;
|
|
2097
2247
|
constructor(config = {}) {
|
|
2098
2248
|
const baseUrl = config.baseUrl ?? readEnv("GIGADRIVE_API_BASE_URL") ?? DEFAULT_BASE_URL2;
|
|
2099
2249
|
const fetchFn = config.fetch ?? globalThis.fetch.bind(globalThis);
|
|
@@ -2105,6 +2255,7 @@ var GigadriveClient = class {
|
|
|
2105
2255
|
this.deployments = new DeploymentsResource(httpClient);
|
|
2106
2256
|
this.aiGateway = new AiGatewayResource(httpClient);
|
|
2107
2257
|
this.apiKeys = new ApiKeysResource(httpClient);
|
|
2258
|
+
this.stickySessions = new StickySessionsResource(httpClient);
|
|
2108
2259
|
}
|
|
2109
2260
|
};
|
|
2110
2261
|
|
|
@@ -2138,7 +2289,10 @@ export {
|
|
|
2138
2289
|
GigadriveError,
|
|
2139
2290
|
OrganizationAiGatewayResource,
|
|
2140
2291
|
OrganizationEnvVarsResource,
|
|
2292
|
+
OrganizationMembersResource,
|
|
2293
|
+
OrganizationProductsResource,
|
|
2141
2294
|
OrganizationsResource,
|
|
2295
|
+
StickySessionsResource,
|
|
2142
2296
|
StorageBucketsResource,
|
|
2143
2297
|
StorageObjectsResource,
|
|
2144
2298
|
StorageUploadSessionsResource,
|