teta_cms 0.1.7+4 copy "teta_cms: ^0.1.7+4" to clipboard
teta_cms: ^0.1.7+4 copied to clipboard

discontinued
outdated

The Dart client for Teta CMS. Our mission is to help people build amazing products.

Teta CMS #

pub package

The Dart client for Teta CMS

Teta dashboard screenshots

Introducing Teta CMS #

Teta CMS is a low-code back-end service. We provide:

  • Scalable NoSQL database
  • Real-time subscriptions
  • User authentication system and policies
  • Perform custom queries on your collections with our Ayaya language
  • Use an easy-to-use and responsive user interface

Getting Started #

To use Teta CMS you have to create first a project on Teta.so

Compatibility #

Auth Database Ayaya Realtime Analytics
Android
iOS
Web
macOS Coming soon
Windows Coming soon
Linux Coming soon

Examples #

Initialize #

To get the credentials, go to Teta > project dashboard > Getting Started

Since you call the .initialize method, you are able to use Teta.instance anywhere in your application

import 'package:teta_cms/teta_cms.dart';

void main() {
  TetaCMS.initialize(
    token: prjToken,
    prjId: prjId,
  );
  
  runApp(
    // Your app...
  );
}

Database with custom query #

Making a query with the Ayaya language

// Fetch all docs in `CollectionA` created less than a week, ordering by `created_at`
final response = await TetaCMS.instance.client.query(
  r'''
    MATCH name EQ CollectionA;
    IN docs;
    MATCH created_at GT DATESUB($now $week);
    SORT created_at -1;
    LIMIT 20;
  ''', 
);

// Check if it returns an error
if (response.error != null) {
  debugPrint('${response.error?.message}');
} else {
  // Safe to use response.data 🎉
}

With Ayaya, you can join two or more collections:

// Fetch all docs in `Collection1` and `Collection2`
final response = await TetaCMS.instance.client.query(
  '''
    MATCHOR name EQ Collection1 name EQ Collection2;
  ''', 
);

Fetch docs #

// Fetch all docs by `collectionId`, ordering and filtering
final List<dynamic> response = await TetaCMS.instance.client.getCollection(
  collectionId, // You can retrieve this from your project dashboard
  limit: 10,
  page: 0,
  showDrafts: false,
  filters: [
    Filter(
      'Key',
      'Value',
      type: FilterType.like,
    ),
  ],
);

Or you can use our TetaFutureBuilder. It manages the cache by preventing unwanted calls.

TetaFutureBuilder(
  future: TetaCMS.instance.client.getCollection(
    collectionId, // You can retrieve this from your project dashboard
  ), 
  builder: (final context, final snap) {
    // build your widgets with snap.data as List<dynamic>
  },
);

TetaFutureBuilder supports any future. You can also use it to run an Ayaya query.

See other examples.

Realtime #

// Stream all docs by `collectionId` ordering and filtering
final StreamController<List<dynamic>> controller = TetaCMS.instance.realtime.streamCollection(
  collectionId, // You can retrieve this from your project dashboard
  limit: 10,
  page: 0,
  showDrafts: false,
  filters: [
    Filter(
      'Key',
      'Value',
      type: FilterType.like,
    ),
  ],
);

// Remember to close it when you're done
controller.close();

Or you can use our TetaStreamBuilder. It manages the cache by preventing unwanted calls and closes the stream controller at the dispose event.

TetaStreamBuilder(
  stream: TetaCMS.instance.realtime.streamCollection(
    collectionId, // You can retrieve this from your project dashboard
  ), 
  builder: (final context, final snap) {
    // build your widgets with snap.data as List<dynamic>
  },
);

Social authentication #

// Sign up user with Apple OAuth provider
TetaCMS.instance.auth.signIn(
  provider: TetaProvider.apple,
  onSuccess: (final isFirstTime) async {
    // Success 🎉
  );
);

The isFirstTime flag tells us whether the user is a first-time login, which is useful if we only need to perform actions for the first time.​

Retrieve current user #

// Get the current user
final TetaUser user = await TetaCMS.instance.auth.user.get;
if (user.isLogged) {
  // The user is logged 🎉
} else {
  // There is no current user
}

Sign Out #

await TetaCMS.instance.auth.signOut();

Teta Auth configuration #

Authentication with Teta CMS works by opening a browser to allow people to log in using different providers. This method allows us to write much less code.

To open a browser and return to the application after successful login, you need to configure the deeplink in your application.

Set your redirect URL #

  • Go to app.teta.so > Project dashboard > Users > Config
  • Fill the Redirect Url field (eg. com.example.app://welcome following the format SCHEME://HOSTNAME)

Teta Auth redirect URL field

Teta social OAuth config #

Follow our docs for the following OAuth providers:

Android #

Declare your Redirect Url inside the ActivityManifest.xml file. In this example we are using the value com.example.app://welcome

<manifest ...>
  <application ...>
    <activity ...>
      <!-- ... -->

      <!-- Teta Auth Deeplink -->
      <intent-filter>
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <!-- Your redirect URL -->
        <data
          android:scheme="com.example.app"
          android:host="welcome" />
      </intent-filter>
    </activity>
  </application>
</manifest>

Android docs: https://developer.android.com/training/app-links/deep-linking

iOS #

Declare your Redirect Url inside the ios/Runner/Info.plist file. In this example we are using the value com.example.app://welcome

<plist>
<dict>
  <!-- Teta Auth Deeplink -->
  <key>CFBundleURLTypes</key>
  <array>
    <dict>
      <key>CFBundleTypeRole</key>
      <string>Editor</string>
      <key>CFBundleURLSchemes</key>
      <array>
        <string>com.example.app</string>
      </array>
    </dict>
  </array>
  <!-- ... -->
</dict>
</plist>

Apple docs: https://developer.apple.com/documentation/xcode/defining-a-custom-url-scheme-for-your-app

Web #

Nothing needs to be set up for the Web.

Windows, macOS, Linux #

Authentication for desktop platforms is coming soon.


Tutorials #

This section will be updated whenever a new tutorial is released

Docs #

See our Flutter docs on teta.so/flutter-docs

Teta CMS is still in open alpha #

  • ✅ Closed Alpha;
  • ✅ Open Alpha: We could still introduce some big changes;
  • ❌ Open Alpha: Expect bugs, but it is ready for testing and side projects;
  • ❌ Beta: first stable version;
  • ❌ Teta: we are finally full Teta;

We are just at the beginning, and we still have a long way to go.

Let us know what you think, we thank you for your support :) #

Reaction