@composable-os/pack-offers 0.0.0-stage → 0.1.0-beta.16

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,109 @@
1
+ # Functional Source License, Version 1.1, ALv2 Future License
2
+
3
+ > This licence covers the repository except the directories listed in NOTICE. In particular, the
4
+ > assistant packages `packages/agent-*` (agent-core, agent-a2ui, agent-voice, agent-plugins) are
5
+ > licensed under the MIT License; see the LICENSE file in each of those directories (ADR 0350).
6
+
7
+ ## Abbreviation
8
+
9
+ FSL-1.1-ALv2
10
+
11
+ ## Notice
12
+
13
+ Copyright 2026 Tim O'Connell
14
+
15
+ ## Terms and Conditions
16
+
17
+ ### Licensor ("We")
18
+
19
+ The party offering the Software under these Terms and Conditions.
20
+
21
+ ### The Software
22
+
23
+ The "Software" is each version of the software that we make available under
24
+ these Terms and Conditions, as indicated by our inclusion of these Terms and
25
+ Conditions with the Software.
26
+
27
+ ### License Grant
28
+
29
+ Subject to your compliance with this License Grant and the Patents,
30
+ Redistribution and Trademark clauses below, we hereby grant you the right to
31
+ use, copy, modify, create derivative works, publicly perform, publicly display
32
+ and redistribute the Software for any Permitted Purpose identified below.
33
+
34
+ ### Permitted Purpose
35
+
36
+ A Permitted Purpose is any purpose other than a Competing Use. A Competing Use
37
+ means making the Software available to others in a commercial product or
38
+ service that:
39
+
40
+ 1. substitutes for the Software;
41
+
42
+ 2. substitutes for any other product or service we offer using the Software
43
+ that exists as of the date we make the Software available; or
44
+
45
+ 3. offers the same or substantially similar functionality as the Software.
46
+
47
+ Permitted Purposes specifically include using the Software:
48
+
49
+ 1. for your internal use and access;
50
+
51
+ 2. for non-commercial education;
52
+
53
+ 3. for non-commercial research; and
54
+
55
+ 4. in connection with professional services that you provide to a licensee
56
+ using the Software in accordance with these Terms and Conditions.
57
+
58
+ ### Patents
59
+
60
+ To the extent your use for a Permitted Purpose would necessarily infringe our
61
+ patents, the license grant above includes a license under our patents. If you
62
+ make a claim against any party that the Software infringes or contributes to
63
+ the infringement of any patent, then your patent license to the Software ends
64
+ immediately.
65
+
66
+ ### Redistribution
67
+
68
+ The Terms and Conditions apply to all copies, modifications and derivatives of
69
+ the Software.
70
+
71
+ If you redistribute any copies, modifications or derivatives of the Software,
72
+ you must include a copy of or a link to these Terms and Conditions and not
73
+ remove any copyright notices provided in or with the Software.
74
+
75
+ ### Disclaimer
76
+
77
+ THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTIES OF ANY KIND, EXPRESS OR
78
+ IMPLIED, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR
79
+ PURPOSE, MERCHANTABILITY, TITLE OR NON-INFRINGEMENT.
80
+
81
+ IN NO EVENT WILL WE HAVE ANY LIABILITY TO YOU ARISING OUT OF OR RELATED TO THE
82
+ SOFTWARE, INCLUDING INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES,
83
+ EVEN IF WE HAVE BEEN INFORMED OF THEIR POSSIBILITY IN ADVANCE.
84
+
85
+ ### Trademarks
86
+
87
+ Except for displaying the License Details and identifying us as the origin of
88
+ the Software, you have no right under these Terms and Conditions to use our
89
+ trademarks, trade names, service marks or product names.
90
+
91
+ ## Grant of Future License
92
+
93
+ We hereby irrevocably grant you an additional license to use the Software under
94
+ the Apache License, Version 2.0 that is effective on the second anniversary of
95
+ the date we make the Software available. On or after that date, you may use the
96
+ Software under the Apache License, Version 2.0, in which case the following
97
+ will apply:
98
+
99
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use
100
+ this file except in compliance with the License.
101
+
102
+ You may obtain a copy of the License at
103
+
104
+ http://www.apache.org/licenses/LICENSE-2.0
105
+
106
+ Unless required by applicable law or agreed to in writing, software distributed
107
+ under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
108
+ CONDITIONS OF ANY KIND, either express or implied. See the License for the
109
+ specific language governing permissions and limitations under the License.
@@ -0,0 +1,5 @@
1
+ import type { DashboardDeclaration } from "@composable-os/sdk";
2
+ export declare const offersOverview: DashboardDeclaration;
3
+ export declare const offersDashboards: {
4
+ offersOverview: DashboardDeclaration;
5
+ };
@@ -0,0 +1,85 @@
1
+ const USED = `FROM rec_discount_use u
2
+ JOIN rec_x_offers_discount d ON d.id = u.discount_id
3
+ WHERE u.state = 'used' AND u.created_at >= :used_from AND u.created_at < :used_to`;
4
+ export const offersOverview = {
5
+ title: "Offers",
6
+ description: "Which discounts are live, the money they took off paid orders, and the orders and revenue " +
7
+ "each brought in.",
8
+ filters: [{ type: "dateRange", id: "used", label: "Ordered", default: "this_month" }],
9
+ widgets: [
10
+ {
11
+ id: "live",
12
+ type: "kpi",
13
+ title: "Live discounts",
14
+ description: "Discounts the host applies now (their own dates aside).",
15
+ sql: "SELECT count(*) AS value FROM rec_x_offers_discount d WHERE d.state = 'active'",
16
+ mapping: { value: "value" },
17
+ options: { compare: false },
18
+ clickThrough: {
19
+ object: "offers.discount",
20
+ filter: { field: "state", op: "eq", value: "active" },
21
+ },
22
+ layout: { w: 3, h: 1 },
23
+ },
24
+ {
25
+ id: "given",
26
+ type: "kpi",
27
+ title: "Discount given",
28
+ description: "Money discounts took off orders paid, started in the period.",
29
+ sql: `SELECT coalesce(sum(u.amount), 0) / 100.0 AS value ${USED}`,
30
+ mapping: { value: "value" },
31
+ options: { compare: true, format: "currency" },
32
+ layout: { w: 3, h: 1 },
33
+ },
34
+ {
35
+ id: "orders",
36
+ type: "kpi",
37
+ title: "Orders with a discount",
38
+ description: "Paid orders, started in the period, that a discount applied to.",
39
+ sql: `SELECT count(*) AS value ${USED}`,
40
+ mapping: { value: "value" },
41
+ options: { compare: true },
42
+ layout: { w: 3, h: 1 },
43
+ },
44
+ {
45
+ id: "revenue",
46
+ type: "kpi",
47
+ title: "Revenue with a discount",
48
+ description: "What those orders cost their buyers, after the discount.",
49
+ sql: `SELECT coalesce(sum(u.order_total), 0) / 100.0 AS value ${USED}`,
50
+ mapping: { value: "value" },
51
+ options: { compare: true, format: "currency" },
52
+ layout: { w: 3, h: 1 },
53
+ },
54
+ {
55
+ id: "per-discount",
56
+ type: "table",
57
+ title: "By discount",
58
+ description: "Each discount used on paid orders started in the period: how many orders, the money it " +
59
+ "took off and what the orders came to after it.",
60
+ sql: `SELECT d.id AS id, d.name AS discount, d.state AS state, count(*) AS orders,
61
+ coalesce(sum(u.amount), 0) / 100.0 AS given, coalesce(sum(u.order_total), 0) / 100.0 AS revenue
62
+ ${USED}
63
+ GROUP BY d.id, d.name, d.state ORDER BY given DESC LIMIT 100`,
64
+ mapping: { columns: ["discount", "state", "orders", "given", "revenue"] },
65
+ clickThrough: {
66
+ object: "offers.discount",
67
+ filter: { field: "id", op: "eq", value: { $row: "id" } },
68
+ },
69
+ layout: { w: 12, h: 2 },
70
+ },
71
+ {
72
+ id: "by-kind",
73
+ type: "donut",
74
+ title: "By code or by itself",
75
+ description: "Money off paid orders in the period, by a code or a price that applies itself.",
76
+ sql: `SELECT CASE u.kind WHEN 'code' THEN 'By a code' ELSE 'By itself' END AS label,
77
+ coalesce(sum(u.amount), 0) / 100.0 AS value
78
+ ${USED}
79
+ GROUP BY label`,
80
+ mapping: { label: "label", value: "value" },
81
+ layout: { w: 6, h: 2 },
82
+ },
83
+ ],
84
+ };
85
+ export const offersDashboards = { offersOverview };