Token导航 LogoToken导航TokenDH.com
研究检索需要联网github未标认证来源可访问许可证需确认审计通过

constructive-services-schemas建设性服务模式

Agent Skill

constructive-services-schemas 用于查找、检索和筛选相关信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要根据关键词、任务场景或来源线索快速定位候选结果时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

380

周安装

16

GitHub Stars

公开资料未说明

下载量

133
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:constructive-services-schemas(建设性服务模式)
来源仓库:https://github.com/constructive-io/constructive-skills
仓库路径:skills/constructive-services-schemas
安装命令:
npx skills add https://github.com/constructive-io/constructive-skills --skill constructive-services-schemas
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/constructive-io/constructive-skills --skill constructive-services-schemas

简介

通过 TypeScript SDK 配置 Constructive 服务、绑定数据库 schema 并设置路由。

  • 支持零 SQL 操作完成 API 创建、域名校验和角色权限分配。
  • 适用于快速搭建多租户 SaaS 平台的后端服务能力。
  • 需了解实体层级结构(数据库→API→schema→domain)的组织逻辑。
  • constructive-services-schemas 属于研究检索类 Skill,可作为该场景下的辅助能力补充。

SKILL.md

Constructive Services & Schemas

Configure Constructive services (APIs), attach database schemas, set up domain routing, and manage access — all via the @constructive-io/sdk TypeScript SDK with zero SQL.

When to Apply

Use this skill when:

  • Creating a new API service for a Constructive database
  • Attaching database schemas to an API to expose them via GraphQL
  • Setting up domain/subdomain routing for APIs and sites
  • Adding configuration modules to an API
  • Granting role-based access to schemas
  • Querying existing APIs with their attached schemas and domains

Core Concepts

Entity Hierarchy

Database (top-level container)
├── Schema (database schema, e.g. "public" — auto-created with database)
│   ├── Table, View, SchemaGrant, ...
│   └── ApiSchema (join: links Schema ↔ Api)
├── Api (service endpoint with role-based access)
│   ├── ApiSchema (which schemas this API exposes)
│   ├── ApiModule (named JSON config blobs)
│   └── Domain (routing: subdomain.domain → this API)
├── Site (website metadata: title, logo, favicon, etc.)
│   └── Domain (routing: subdomain.domain → this site)
└── Domain (maps subdomain + domain to an Api and/or Site)

Key Relationships

EntityPurposeKey Fields
ApiA service endpointdatabaseId, name, roleName, anonRole, isPublic
ApiSchemaLinks an Api to a SchemadatabaseId, apiId, schemaId
ApiModuleNamed JSON config for an ApidatabaseId, apiId, name, data
DomainRoutes subdomain.domain → Api/SitedatabaseId, apiId, siteId, subdomain, domain
SchemaDatabase schema containerdatabaseId, name, schemaName
SchemaGrantGrants a role access to a schemadatabaseId, schemaId, granteeName

Every entity requires a databaseId — the UUID of the parent Database.

SDK Setup

import { createClient } from '@constructive-io/sdk';

const sdk = createClient({
  endpoint: 'https://your-constructive-api.example.com/graphql',
  headers: { Authorization: 'Bearer <token>' },
});

Creating an API

An API defines a service endpoint with role-based access control.

const result = await sdk.api
  .create({
    data: {
      databaseId,            // required: parent database UUID
      name: 'public',        // required: API name
      roleName: 'authenticated', // role for authenticated users
      anonRole: 'anonymous',    // role for anonymous access
      isPublic: true,           // whether the API is publicly accessible
    },
    select: { id: true, name: true, databaseId: true },
  })
  .execute();

if (!result.ok) {
  throw new Error(`createApi failed: ${JSON.stringify(result.errors)}`);
}

const api = result.data.createApi.api;

Required fields for api.create:

  • databaseId (string) — parent database UUID
  • name (string) — API name (e.g., "public", "admin", "meta")

Optional fields:

  • dbname (string) — database name override
  • roleName (string) — role for authenticated users (e.g., "authenticated", "administrator")
  • anonRole (string) — role for anonymous access (e.g., "anonymous", "administrator")
  • isPublic (boolean) — whether the API is publicly accessible

Attaching Schemas to an API

Use apiSchema to link a Schema to an Api. This is a many-to-many join — one API can expose multiple schemas, and one schema can be exposed by multiple APIs.

const linkResult = await sdk.apiSchema
  .create({
    data: {
      databaseId,   // required: parent database UUID
      apiId: api.id, // required: the API to attach to
      schemaId: publicSchema.id, // required: the schema to expose
    },
    select: { id: true },
  })
  .execute();

if (!linkResult.ok) {
  throw new Error(`createApiSchema failed: ${JSON.stringify(linkResult.errors)}`);
}

Required fields for apiSchema.create:

  • databaseId (string)
  • apiId (string) — the API to attach the schema to
  • schemaId (string) — the schema to expose through this API

Attaching multiple schemas to one API:

const schemaIds = [publicSchemaId, usersSchemaId, authSchemaId];

for (const schemaId of schemaIds) {
  await sdk.apiSchema
    .create({
      data: { databaseId, apiId: api.id, schemaId },
      select: { id: true },
    })
    .execute();
}

Setting Up Domains

Domains route subdomain.domain to an API and/or Site. Create the domain first, then link it to an API.

Step 1: Create domains

const domainResult = await sdk.domain
  .create({
    data: {
      databaseId,
      subdomain: 'api',       // the subdomain part
      domain: 'example.com',  // the domain part
    },
    select: { id: true, subdomain: true, domain: true },
  })
  .execute();

if (!domainResult.ok) {
  throw new Error(`createDomain failed: ${JSON.stringify(domainResult.errors)}`);
}

const domain = domainResult.data.createDomain.domain;

Step 2: Link domain to an API

const updateResult = await sdk.domain
  .update({
    where: { id: domain.id },
    data: { apiId: api.id },
    select: { id: true, apiId: true },
  })
  .execute();

Required fields for domain.create:

  • databaseId (string)

Optional fields:

  • apiId (string) — link to an API at creation time
  • siteId (string) — link to a Site
  • subdomain (string) — e.g., "api", "app", "admin"
  • domain (string) — e.g., "example.com", "localhost"

Adding API Modules

API modules attach named JSON configuration to an API.

const moduleResult = await sdk.apiModule
  .create({
    data: {
      databaseId,
      apiId: api.id,
      name: 'cors_config',       // required: module name
      data: {                     // required: JSON config data
        allowedOrigins: ['https://app.example.com'],
        allowedMethods: ['GET', 'POST'],
        maxAge: 86400,
      },
    },
    select: { id: true, name: true },
  })
  .execute();

Required fields for apiModule.create:

  • databaseId (string)
  • apiId (string) — the API this module belongs to
  • name (string) — module name
  • data (JSON object) — module configuration

Granting Schema Access

Schema grants control which roles can access a schema.

const grantResult = await sdk.schemaGrant
  .create({
    data: {
      schemaId: publicSchema.id,
      granteeName: 'authenticated',  // role name to grant access to
    },
    select: { id: true },
  })
  .execute();

Required fields for schemaGrant.create:

  • schemaId (string) — the schema to grant access to
  • granteeName (string) — the role name (e.g., "authenticated", "anonymous")

Optional fields:

  • databaseId (string)

Querying APIs with Relations

List all APIs with their schemas and domains

const apis = await sdk.api
  .findMany({
    select: {
      id: true,
      name: true,
      roleName: true,
      anonRole: true,
      isPublic: true,
      apiSchemas: {
        select: {
          id: true,
          schema: {
            select: { id: true, name: true, schemaName: true },
          },
        },
      },
      domains: {
        select: { id: true, subdomain: true, domain: true },
      },
      apiModules: {
        select: { id: true, name: true, data: true },
      },
    },
  })
  .execute();

Find a specific API by name

const result = await sdk.api
  .findFirst({
    where: { name: { equalTo: 'public' } },
    select: {
      id: true,
      name: true,
      apiSchemas: {
        select: {
          schema: { select: { id: true, name: true } },
        },
      },
    },
  })
  .execute();

Query a schema with its API links

const schemaResult = await sdk.schema
  .findFirst({
    where: { name: { equalTo: 'public' } },
    select: {
      id: true,
      name: true,
      schemaName: true,
      apiSchemas: {
        select: {
          api: { select: { id: true, name: true } },
        },
      },
      schemaGrants: {
        select: { id: true, granteeName: true },
      },
    },
  })
  .execute();

Complete End-to-End Example

This example shows a full service setup workflow: create a database, set up multiple APIs with different roles, attach schemas, configure domains, and add site metadata.

import { createClient } from '@constructive-io/sdk';

const sdk = createClient({
  endpoint: 'https://your-api.example.com/graphql',
  headers: { Authorization: 'Bearer <token>' },
});

// 1. Create a database (schemas like "public" are auto-created)
const dbResult = await sdk.database
  .create({
    data: { name: 'my-project', ownerId: userId },
    select: {
      id: true,
      schemas: { select: { id: true, name: true }, first: 10 },
    },
  })
  .execute();

const database = dbResult.data.createDatabase.database;
const databaseId = database.id;
const publicSchema = database.schemas?.nodes?.find(
  (s) => s.name === 'public'
);

// 2. Create domains for routing
const subdomains = ['api', 'app', 'meta'];
const domains: Record<string, string> = {};

for (const subdomain of subdomains) {
  const domainResult = await sdk.domain
    .create({
      data: { databaseId, subdomain, domain: 'localhost' },
      select: { id: true },
    })
    .execute();
  domains[subdomain] = domainResult.data.createDomain.domain.id;
}

// 3. Helper: create an API, attach schemas, and link a domain
async function setupApi(opts: {
  name: string;
  roleName: string;
  anonRole: string;
  schemaIds?: string[];
  domainId: string;
}) {
  // Create the API
  const apiResult = await sdk.api
    .create({
      data: {
        databaseId,
        name: opts.name,
        roleName: opts.roleName,
        anonRole: opts.anonRole,
        isPublic: true,
      },
      select: { id: true, name: true },
    })
    .execute();

  const api = apiResult.data.createApi.api;

  // Attach schemas
  for (const schemaId of opts.schemaIds ?? []) {
    await sdk.apiSchema
      .create({
        data: { databaseId, apiId: api.id, schemaId },
        select: { id: true },
      })
      .execute();
  }

  // Link domain to this API
  await sdk.domain
    .update({
      where: { id: opts.domainId },
      data: { apiId: api.id },
      select: { id: true },
    })
    .execute();

  return api;
}

// 4. Set up services
await setupApi({
  name: 'public',
  roleName: 'authenticated',
  anonRole: 'anonymous',
  schemaIds: [publicSchema.id],
  domainId: domains['api'],
});

await setupApi({
  name: 'meta',
  roleName: 'authenticated',
  anonRole: 'anonymous',
  domainId: domains['meta'],
});

// 5. Create a site and link it to the app domain
const siteResult = await sdk.site
  .create({
    data: {
      databaseId,
      title: 'My App',
      description: 'My Constructive application',
    },
    select: { id: true },
  })
  .execute();

await sdk.domain
  .update({
    where: { id: domains['app'] },
    data: { siteId: siteResult.data.createSite.site.id },
    select: { id: true },
  })
  .execute();

Updating and Deleting

Update an API

await sdk.api
  .update({
    where: { id: apiId },
    data: { isPublic: false, anonRole: 'authenticated' },
    select: { id: true, isPublic: true },
  })
  .execute();

Remove a schema from an API

await sdk.apiSchema
  .delete({
    where: { id: apiSchemaId },
    select: { id: true },
  })
  .execute();

Delete a domain

await sdk.domain
  .delete({
    where: { id: domainId },
    select: { id: true },
  })
  .execute();

Common Patterns

Multiple APIs, same database

A single database typically has several APIs with different access levels:

API NameroleNameanonRolePurpose
publicauthenticatedanonymousPublic-facing API
metaauthenticatedanonymousMetadata/schema introspection
DANGEROUS — Development/Testing Only! APIs with administrator as both roleName and anonRole (e.g., admin, super) should never exist in production. These grant full administrator access to anonymous users. They are only used in local development and test environments. If you see administrator APIs in a production setup, treat it as a critical security misconfiguration.

Domain routing pattern

Each API gets its own subdomain:

SubdomainDomainLinked To
apiexample.compublic API
appexample.comSite (frontend)
metaexample.commeta API

Error Handling

All SDK operations return a discriminated union. Always check .ok:

const result = await sdk.api.create({ ... }).execute();

if (!result.ok) {
  console.error('Failed:', result.errors);
  // result.errors is GraphQLError[]
  return;
}

// Safe to access result.data
const api = result.data.createApi.api;

Or use .unwrap() to throw on error:

const data = await sdk.api.create({ ... }).unwrap();
const api = data.createApi.api;

References

  • For detailed ORM field reference, see references/entity-fields.md
  • Related skill: constructive-graphql-codegen — generate the typed SDK
  • Related skill: constructive-functions — build cloud functions using the SDK

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

37.83%
按下载量换算50

Claude

30.79%
按下载量换算41

Cursor

17.2%
按下载量换算23

Gemini CLI

8.81%
按下载量换算12

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills