@flipdish/orgmanagement

中文文档
2.0.1发布于 2026/11/13UnlicenseTypeScriptESM + CJS零依赖近 30 天下载 2535

管理Flipdish客户组织、品牌、财产和销售渠道的API.

中文使用文档
文档目录3 节
  1. @flipdish/org 管理层
  2. 示例代码
  3. 客户身份

@flipdish/org 管理层

这个软件包为Flipdish的组织管理API提供了TypeScript/JavaScript客户端,覆盖了HTTP.

它的产生与 嘿,API(英语: 并使用本地语言 fetch API,所以它没有运行时间依赖性. 它在Node.js 18+, Bun, Deno和浏览器中工作,并同时运送ES模块和CommonJS.

示例代码

import { createFlipdishClient, SDK_INFO } from "@flipdish/orgmanagement";
import { describe, expect, test } from "@jest/globals";

const orgManagement = createFlipdishClient({
  baseUrl: "https://api-prod-staging.flipdishdev.com",
  // to get the API key, you should follow these docs:
  // https://developers.flipdish.com/docs/getting-started
  accessToken: process.env.FLIPDISH_BEARER_TOKEN,
  // optional: identifies your app in the X-Flipdish-Client header,
  // and in User-Agent outside browsers. Defaults to env vars such as DD_SERVICE.
  clientName: "sdk-test-app",
});

describe("Org Management Tests", () => {
  describe("Orgs", () => {
    // test("Get org by id", async () => {
    //   const { data, error } = await orgManagement.getOrgById({
    //     path: { orgId: "org12345" },
    //   });
    //   expect(error).toBeUndefined();
    //   expect(data?.data.orgId).toBe("org12345");
    // });

    test("client is created", () => {
      expect(orgManagement.getAllOrgs).toBeInstanceOf(Function);
    });
  });

  describe("Client identity", () => {
    test("sends User-Agent and X-Flipdish-Client in Node", async () => {
      let sent: Request | undefined;
      const sdk = createFlipdishClient({
        clientName: "sdk-test-app",
        clientVersion: "1.2.3",
        fetch: async (input) => {
          sent = input as Request;
          return new Response(JSON.stringify({ data: [] }), {
            headers: { "content-type": "application/json" },
          });
        },
      });

      await sdk.getAllOrgs();

      const expected = `Flipdish-orgmanagement-ts/${SDK_INFO.version} sdk-test-app/1.2.3`;
      expect(sent?.headers.get("user-agent")).toMatch(
        new RegExp(`^${expected.replace(/[.+]/g, "\\$&")} `),
      );
      expect(sent?.headers.get("x-flipdish-client")).toBe(
        sent?.headers.get("user-agent"),
      );
    });
  });
});

客户身份

每个请求都包含 X-Flipdish-Client 识别SDK和应用程序的头条 外部浏览器同样值也被发送为 User-Agent,例如:

Flipdish-orgmanagement-ts/2.0.1 menu-service/2.3.1 env/production node/22.18.0

每个部分都可以被设定在代码中,或者使用环境变量. 第一个被设定的获胜者, 请先选中选项 :

编选项环境变量
应用名称clientNameFLIPDISH_CLIENT_NAME, (中文(简体) ), DD_SERVICE, (中文(简体) ), AWS_LAMBDA_FUNCTION_NAME, (中文(简体) ), npm_package_name
App 版本clientVersionFLIPDISH_CLIENT_VERSION, (中文(简体) ), DD_VERSION, (中文(简体) ), npm_package_version
环境clientEnvironmentFLIPDISH_CLIENT_ENVIRONMENT, (中文(简体) ), DD_ENV, (中文(简体) ), NODE_ENV
运行时间runtimeFLIPDISH_CLIENT_RUNTIME,然后检测出节点.js、 Bun 或 Deno 版本
后缀userAgentSuffixFLIPDISH_CLIENT_USER_AGENT_SUFFIX

将选项传递到 createFlipdishClient,或打电话 configureClientIdentity 设置默认值 client数字 :

import { configureClientIdentity } from "@flipdish/orgmanagement";

configureClientIdentity({ clientName: "menu-service", clientVersion: "2.3.1", clientEnvironment: "production" });

浏览器没有环境变量, 因此至少设定 clientName 在代码那里。 任何传入的东西 headers 覆盖这些值.

版本与发布记录

@flipdish/orgmanagement 共发布 366 个版本,首次发布于 2024/08/28;过去 12 个月发布了 104 个版本。

版本发布日期距今
2.0.1latest2026/11/132 天前
2.0.1-rc.1794581463next2026/11/132 天前
2.0.02026/11/132 天前
2.0.0-rc.17945799652026/11/132 天前
0.0.0-preview.183.g0a86e1epreview2026/11/123 天前
1.1.772026/10/2917 天前

关于 @flipdish/orgmanagement 的常见问题

@flipdish/orgmanagement 是什么?

管理Flipdish客户组织、品牌、财产和销售渠道的API.

如何安装 @flipdish/orgmanagement?

在项目目录运行 npm install @flipdish/orgmanagement,或使用 pnpm add / yarn add / bun add。

@flipdish/orgmanagement 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@flipdish/orgmanagement 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@flipdish/orgmanagement 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=18。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@flipdish/orgmanagement 可以商用吗?

@flipdish/orgmanagement 使用 Unlicense 许可。作者将代码贡献到公共领域,可不受限制地使用。以上为概括,不构成法律意见,请以许可原文为准。

@flipdish/orgmanagement 的下载量有多少?

根据 npm 官方下载统计,@flipdish/orgmanagement 在 2026/10/15 – 2026/11/13 这 30 天内被下载 2,535 次,日均约 85 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@flipdish/orgmanagement 还在维护吗?

最新版本 2.0.1 发布于 2026/11/13(2 天前);至今共发布 366 个版本,其中过去 12 个月发布了 104 个;首次发布于 2024/08/28。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。