@flipfeatureflag/next 0.1.1
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/dist/index.d.mts +10 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +56 -0
- package/dist/index.mjs +28 -0
- package/package.json +28 -0
- package/src/index.ts +37 -0
- package/tsconfig.json +7 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from '@flipfeatureflag/react';
|
|
2
|
+
import { FlipFlagClientOptions, SdkContext, FlipFlagClient, SdkEvaluateResponse } from '@flipfeatureflag/core';
|
|
3
|
+
|
|
4
|
+
interface NextServerClientOptions extends FlipFlagClientOptions {
|
|
5
|
+
context: SdkContext;
|
|
6
|
+
}
|
|
7
|
+
declare function createServerClient(options: NextServerClientOptions): FlipFlagClient;
|
|
8
|
+
declare function getServerFlags(options: NextServerClientOptions, flagKeys?: string[]): Promise<SdkEvaluateResponse>;
|
|
9
|
+
|
|
10
|
+
export { type NextServerClientOptions, createServerClient, getServerFlags };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from '@flipfeatureflag/react';
|
|
2
|
+
import { FlipFlagClientOptions, SdkContext, FlipFlagClient, SdkEvaluateResponse } from '@flipfeatureflag/core';
|
|
3
|
+
|
|
4
|
+
interface NextServerClientOptions extends FlipFlagClientOptions {
|
|
5
|
+
context: SdkContext;
|
|
6
|
+
}
|
|
7
|
+
declare function createServerClient(options: NextServerClientOptions): FlipFlagClient;
|
|
8
|
+
declare function getServerFlags(options: NextServerClientOptions, flagKeys?: string[]): Promise<SdkEvaluateResponse>;
|
|
9
|
+
|
|
10
|
+
export { type NextServerClientOptions, createServerClient, getServerFlags };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
|
|
21
|
+
// src/index.ts
|
|
22
|
+
var index_exports = {};
|
|
23
|
+
__export(index_exports, {
|
|
24
|
+
createServerClient: () => createServerClient,
|
|
25
|
+
getServerFlags: () => getServerFlags
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(index_exports);
|
|
28
|
+
__reExport(index_exports, require("@flipfeatureflag/react"), module.exports);
|
|
29
|
+
var import_node = require("@flipfeatureflag/node");
|
|
30
|
+
function createServerClient(options) {
|
|
31
|
+
return (0, import_node.createClient)({
|
|
32
|
+
...options
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
async function getServerFlags(options, flagKeys) {
|
|
36
|
+
const client = createServerClient(options);
|
|
37
|
+
await client.start();
|
|
38
|
+
const evaluations = client.getAllFlags();
|
|
39
|
+
client.stop();
|
|
40
|
+
if (!flagKeys) {
|
|
41
|
+
return { flags: evaluations };
|
|
42
|
+
}
|
|
43
|
+
const filtered = {};
|
|
44
|
+
for (const key of flagKeys) {
|
|
45
|
+
if (evaluations[key]) {
|
|
46
|
+
filtered[key] = evaluations[key];
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return { flags: filtered };
|
|
50
|
+
}
|
|
51
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
52
|
+
0 && (module.exports = {
|
|
53
|
+
createServerClient,
|
|
54
|
+
getServerFlags,
|
|
55
|
+
...require("@flipfeatureflag/react")
|
|
56
|
+
});
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
export * from "@flipfeatureflag/react";
|
|
3
|
+
import { createClient as createNodeClient } from "@flipfeatureflag/node";
|
|
4
|
+
function createServerClient(options) {
|
|
5
|
+
return createNodeClient({
|
|
6
|
+
...options
|
|
7
|
+
});
|
|
8
|
+
}
|
|
9
|
+
async function getServerFlags(options, flagKeys) {
|
|
10
|
+
const client = createServerClient(options);
|
|
11
|
+
await client.start();
|
|
12
|
+
const evaluations = client.getAllFlags();
|
|
13
|
+
client.stop();
|
|
14
|
+
if (!flagKeys) {
|
|
15
|
+
return { flags: evaluations };
|
|
16
|
+
}
|
|
17
|
+
const filtered = {};
|
|
18
|
+
for (const key of flagKeys) {
|
|
19
|
+
if (evaluations[key]) {
|
|
20
|
+
filtered[key] = evaluations[key];
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return { flags: filtered };
|
|
24
|
+
}
|
|
25
|
+
export {
|
|
26
|
+
createServerClient,
|
|
27
|
+
getServerFlags
|
|
28
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@flipfeatureflag/next",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "flipFeatureFlag Next.js SDK",
|
|
5
|
+
"main": "dist/index.cjs",
|
|
6
|
+
"module": "dist/index.mjs",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.mjs",
|
|
12
|
+
"require": "./dist/index.cjs"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"sideEffects": false,
|
|
16
|
+
"scripts": {
|
|
17
|
+
"build": "tsup src/index.ts --format esm,cjs --dts --external react"
|
|
18
|
+
},
|
|
19
|
+
"peerDependencies": {
|
|
20
|
+
"react": ">=17",
|
|
21
|
+
"next": ">=12"
|
|
22
|
+
},
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"@flipfeatureflag/core": "0.1.0",
|
|
25
|
+
"@flipfeatureflag/react": "0.1.0",
|
|
26
|
+
"@flipfeatureflag/node": "0.1.0"
|
|
27
|
+
}
|
|
28
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export * from "@flipfeatureflag/react";
|
|
2
|
+
|
|
3
|
+
import { FlipFlagClient, FlipFlagClientOptions, SdkContext, SdkEvaluateResponse } from "@flipfeatureflag/core";
|
|
4
|
+
import { createClient as createNodeClient } from "@flipfeatureflag/node";
|
|
5
|
+
|
|
6
|
+
export interface NextServerClientOptions extends FlipFlagClientOptions {
|
|
7
|
+
context: SdkContext;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function createServerClient(options: NextServerClientOptions): FlipFlagClient {
|
|
11
|
+
return createNodeClient({
|
|
12
|
+
...options,
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export async function getServerFlags(
|
|
17
|
+
options: NextServerClientOptions,
|
|
18
|
+
flagKeys?: string[],
|
|
19
|
+
): Promise<SdkEvaluateResponse> {
|
|
20
|
+
const client = createServerClient(options);
|
|
21
|
+
await client.start();
|
|
22
|
+
const evaluations = client.getAllFlags();
|
|
23
|
+
client.stop();
|
|
24
|
+
|
|
25
|
+
if (!flagKeys) {
|
|
26
|
+
return { flags: evaluations };
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const filtered: SdkEvaluateResponse["flags"] = {};
|
|
30
|
+
for (const key of flagKeys) {
|
|
31
|
+
if (evaluations[key]) {
|
|
32
|
+
filtered[key] = evaluations[key];
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return { flags: filtered };
|
|
37
|
+
}
|